浏览代码

added tests & methods to be implemented

Leon 6 年前
父节点
当前提交
6026e5f684

+ 8
- 0
src/main/java/io/zipcoder/microlabs/mastering_loops/NumberUtilities.java 查看文件

@@ -16,6 +16,14 @@ public class NumberUtilities {
16 16
         return null;
17 17
     }
18 18
 
19
+    public static String getRange(int start) {
20
+        return null;
21
+    }
22
+
23
+    public static String getRange(int start, int stop) {
24
+        return null;
25
+    }
26
+
19 27
 
20 28
     public static String getRange(int start, int stop, int step) {
21 29
         return null;

+ 124
- 2
src/test/java/io/zipcoder/microlabs/mastering_loops/NumberUtilitiesTest.java 查看文件

@@ -5,7 +5,113 @@ import org.junit.Test;
5 5
 
6 6
 public class NumberUtilitiesTest {
7 7
     @Test
8
-    public void testGetRange1() {
8
+    public void testGetRange1A() {
9
+        // : Given
10
+        String expected = "0123456789";
11
+        int stop = 11;
12
+
13
+        // : When
14
+        String actual = NumberUtilities.getRange(stop);
15
+
16
+        // : Then
17
+        Assert.assertEquals(expected, actual);
18
+    }
19
+
20
+    @Test
21
+    public void testGetRange2A() {
22
+        // : Given
23
+        String expected = "01234";
24
+        int stop = 5;
25
+
26
+        // : When
27
+        String actual = NumberUtilities.getRange(stop);
28
+
29
+        // : Then
30
+        Assert.assertEquals(expected, actual);
31
+    }
32
+
33
+    @Test
34
+    public void testGetRange3A() {
35
+        // : Given
36
+        String expected = "012345678910111213141516171819";
37
+        int stop = 20;
38
+
39
+        // : When
40
+        String actual = NumberUtilities.getRange(stop);
41
+
42
+        // : Then
43
+        Assert.assertEquals(expected, actual);
44
+    }
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+    @Test
58
+    public void testGetRange1B() {
59
+        // : Given
60
+        String expected = "5678910111213141516171819";
61
+        int start = 5;
62
+        int stop = 20;
63
+
64
+        // : When
65
+        String actual = NumberUtilities.getRange(start, stop);
66
+
67
+        // : Then
68
+        Assert.assertEquals(expected, actual);
69
+    }
70
+
71
+
72
+    @Test
73
+    public void testGetRange2B() {
74
+        // : Given
75
+        String expected = "101112131415161718192021222324";
76
+        int start = 10;
77
+        int stop = 25;
78
+
79
+        // : When
80
+        String actual = NumberUtilities.getRange(start, stop);
81
+
82
+        // : Then
83
+        Assert.assertEquals(expected, actual);
84
+    }
85
+
86
+
87
+    @Test
88
+    public void testGetRange3B() {
89
+        // : Given
90
+        String expected = "100101103104105106107108109";
91
+        int start = 100;
92
+        int stop = 110;
93
+
94
+        // : When
95
+        String actual = NumberUtilities.getRange(start, stop);
96
+
97
+        // : Then
98
+        Assert.assertEquals(expected, actual);
99
+    }
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+    @Test
114
+    public void testGetRange1C() {
9 115
         // : Given
10 116
         String expected = "51015";
11 117
         int start = 5;
@@ -21,7 +127,7 @@ public class NumberUtilitiesTest {
21 127
 
22 128
 
23 129
     @Test
24
-    public void testGetRange2() {
130
+    public void testGetRange2C() {
25 131
         // : Given
26 132
         String expected = "012345678910111213141516171819";
27 133
         int start = 0;
@@ -36,6 +142,22 @@ public class NumberUtilitiesTest {
36 142
     }
37 143
 
38 144
 
145
+    @Test
146
+    public void testGetRange3C() {
147
+        // : Given
148
+        String expected = "0246810";
149
+        int start = 0;
150
+        int stop = 11;
151
+        int step = 2;
152
+
153
+        // : When
154
+        String actual = NumberUtilities.getRange(start, stop, step);
155
+
156
+        // : Then
157
+        Assert.assertEquals(expected, actual);
158
+    }
159
+
160
+
39 161
 
40 162
 
41 163