diff --git a/src/toptal/README.md b/src/toptal/README.md new file mode 100644 index 0000000..87af3a1 --- /dev/null +++ b/src/toptal/README.md @@ -0,0 +1,62 @@ +White Box Testing to function solution + +if (a == null || a.length == 0) + + (1.1) (1.2) +return 0 (1.3) + +if (a.length == 1) + (2 ) + +return 1 (3) + +Set seta (4) + +Set setb (5) + +Set setc (6) + +Set setd (7) + +for (8) + +double d (9) + +int x (10) + +int y (11) + +if (x > 0 && y > 0) (12) + +seta.add (12.1) + +else if (x < 0 && y > 0)(13) + +setb.add(13.1) + +else if (x < 0 && y < 0) (14) + +setc.add(14.1) + +else (15) + +setd.add(15.1) + +return 16 + +=> Case Test + + T1:(1.1) (1.3) + T2:(1.1) (1.2) (1.3) + T3:(1) (2) (3) + T4:(1) (2) (4) (5) (6) (7) (8) (9) (10) (11) (12) (12.1) + (9) (10) (11) (12) (13) (13.1) + (9) (10) (11) (12) (13) (14) (14.1) + (9) (10) (11) (12) (13) (14) (15) (15.1) (16) + T5:(1) (2) (4) (5) (6) (7) (8) (9) (10) (11) (12) (12.1) + (9) (10) (11) (12) (12.1) + (9) (10) (11) (12) (12.1) (16) + ..T6,T7,T8 similar T5 + + + diff --git a/src/toptal/TestingJunit.java b/src/toptal/TestingJunit.java new file mode 100644 index 0000000..b6abd13 --- /dev/null +++ b/src/toptal/TestingJunit.java @@ -0,0 +1,54 @@ +import org.junit.Assert; +import org.junit.Test; +// White Box Testing +public class TestingJunit { + First first =new First(); + + // Test if (a == null || a.length == 0) + @Test + public void TestFirst1(){ + Assert.assertEquals(0,first.solution(null)); + } + + // Test if (a == null || a.length == 0) + @Test + public void TestFirst2(){ + Assert.assertEquals(0,first.solution([])); + } + + // Test if (a.length == 1) + @Test + public void TestFirst3(){ + Assert.assertEquals(1,first.solution([{1,1}]); + } + + // Test for and if + @Test + public void TestFirst4(){ + Assert.assertEquals(4,first.solution([{1,1},{-1,1},{-1,-1},{1,-1}])); + } + + // Test seta.add + @Test + public void TestFirst5(){ + Assert.assertEquals(2,first.solution([{1,1},{4,4},{1,4}])); + } + + // Test setb.add + @Test + public void TestFirst6(){ + Assert.assertEquals(2,first.solution([{-1,1},{-4,4},{-1,4}])); + } + + // Test setc.add + @Test + public void TestFirst7(){ + Assert.assertEquals(2,first.solution([{-1,-1},{-4,-4},{-1,-4}])); + } + + // Test setd.add + @Test + public void TestFirst8(){ + Assert.assertEquals(2,first.solution([{1,-1},{4,-4},{1,-4}])); + } +} \ No newline at end of file