Преглед на файлове

updated junit tests; MathUtilitiesTest

Leon преди 6 години
родител
ревизия
ebf10601f9
променени са 25 файла, в които са добавени 665 реда и са изтрити 286 реда
  1. 158
    52
      src/main/java/com/zipcodewilmington/danny_do_better/PrimativeTypes.java
  2. 55
    0
      src/main/java/com/zipcodewilmington/danny_do_better/StringUtilities.java
  3. 0
    58
      src/main/java/com/zipcodewilmington/danny_do_better/Strings.java
  4. 83
    21
      src/test/java/com/zipcodewilmington/danny_do_better/MathUtilitiesTest.java
  5. 203
    73
      src/test/java/com/zipcodewilmington/danny_do_better/PrimativeTypesTest.java
  6. 166
    0
      src/test/java/com/zipcodewilmington/danny_do_better/StringUtilitiesTest.java
  7. 0
    82
      src/test/java/com/zipcodewilmington/danny_do_better/StringsTest.java
  8. BIN
      target/classes/HelloWorld/HelloWorld.class
  9. BIN
      target/classes/Math/Math.class
  10. BIN
      target/classes/PrimativeTypes/PrimativeTypes.class
  11. BIN
      target/classes/Strings/Strings.class
  12. BIN
      target/classes/Variables/Variables.class
  13. BIN
      target/classes/com/zipcodewilmington/danny_do_better/HelloWorld.class
  14. BIN
      target/classes/com/zipcodewilmington/danny_do_better/MathUtilities.class
  15. BIN
      target/classes/com/zipcodewilmington/danny_do_better/PrimativeTypes.class
  16. BIN
      target/classes/com/zipcodewilmington/danny_do_better/StringUtilities.class
  17. BIN
      target/test-classes/HelloWorld/HelloWorldTest.class
  18. BIN
      target/test-classes/Math/MathTest.class
  19. BIN
      target/test-classes/PrimativeTypes/PrimativeTypesTest.class
  20. BIN
      target/test-classes/Strings/StringsTest.class
  21. BIN
      target/test-classes/Variables/VariablesTest.class
  22. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better/HelloWorldTest.class
  23. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better/MathUtilitiesTest.class
  24. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better/PrimativeTypesTest.class
  25. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better/StringUtilitiesTest.class

+ 158
- 52
src/main/java/com/zipcodewilmington/danny_do_better/PrimativeTypes.java Целия файл

@@ -5,129 +5,235 @@ package com.zipcodewilmington.danny_do_better;
5 5
  */
6 6
 public class PrimativeTypes {
7 7
 
8
-    //Add two ints and return the answer
9
-    public int add(int x, int y){
8
+    /**
9
+     * @param baseValue  starting value
10
+     * @param difference value to add to starting value
11
+     * @return sum of `baseValue` and `difference`
12
+     */
13
+    public int add(int baseValue, int difference) {
10 14
         return 0;
11 15
     }
12 16
 
13
-    //Add two long's and return the answer
14
-    public long add(long x, long y){
17
+    /**
18
+     * @param baseValue  starting value
19
+     * @param difference value to add to starting value
20
+     * @return sum of `baseValue` and `difference`
21
+     */
22
+    public long add(long baseValue, long difference) {
15 23
         return 0;
16 24
     }
17 25
 
18
-    //Add two short's and return the answer Must Type Cast
19
-    public short add(short x, short y){
26
+    /**
27
+     * @param baseValue  starting value
28
+     * @param difference value to add to starting value
29
+     * @return sum of `baseValue` and `difference`
30
+     */
31
+    public short add(short baseValue, short difference) {
20 32
         return 0;
21 33
     }
22
-    //Add two bytes and return the answer, Must Type Cast
23
-    public byte add(byte x, byte y){
34
+
35
+    /**
36
+     * @param baseValue  starting value
37
+     * @param difference value to add to starting value
38
+     * @return sum of `baseValue` and `difference`
39
+     */
40
+    public byte add(byte baseValue, byte difference) {
24 41
         return 0;
25 42
     }
26 43
 
27
-    //Add two floats and return the answer
28
-    public float add(float x, float y){
44
+    /**
45
+     * @param baseValue  starting value
46
+     * @param difference value to add to starting value
47
+     * @return sum of `baseValue` and `difference`
48
+     */
49
+    public float add(float baseValue, float difference) {
29 50
         return 0;
30 51
     }
31 52
 
32
-    //Add two doubles and return the answer
33
-    public double add(double x, double y){
53
+    /**
54
+     * @param baseValue  starting value
55
+     * @param difference value to add to starting value
56
+     * @return sum of `baseValue` and `difference`
57
+     */
58
+    public double add(double baseValue, double difference) {
34 59
         return 0;
35 60
     }
36 61
 
37
-    //Subtract two ints and return the answer
38
-    public int subtract(int x, int y){
62
+    /**
63
+     * @param baseValue  starting value
64
+     * @param difference value to subtract from starting value
65
+     * @return difference between `baseValue` and `difference`
66
+     */
67
+    public int subtract(int baseValue, int difference) {
39 68
         return 0;
40 69
     }
41 70
 
42
-    //Subtract two long's and return the answer
43
-    public long subtract(long x, long y){
71
+    /**
72
+     * @param baseValue  starting value
73
+     * @param difference value to subtract from starting value
74
+     * @return difference between `baseValue` and `difference`
75
+     */
76
+    public long subtract(long baseValue, long difference) {
44 77
         return 0;
45 78
     }
46 79
 
47
-    //Subtract two short's and return the answer Must Type Cast
48
-    public short subtract(short x, short y){
80
+    /**
81
+     * @param baseValue  starting value
82
+     * @param difference value to subtract from starting value
83
+     * @return difference between `baseValue` and `difference`
84
+     */
85
+    public short subtract(short baseValue, short difference) {
49 86
         return 0;
50 87
     }
51
-    //Subtract two bytes and return the answer, Must Type Cast
52
-    public byte subtract(byte x, byte y){
88
+
89
+    /**
90
+     * @param baseValue  starting value
91
+     * @param difference value to subtract from starting value
92
+     * @return difference between `baseValue` and `difference`
93
+     */
94
+    public byte subtract(byte baseValue, byte difference) {
53 95
         return 0;
54 96
     }
55 97
 
56
-    //Subtract two floats and return the answer
57
-    public float subtract(float x, float y){
98
+    /**
99
+     * @param baseValue  starting value
100
+     * @param difference value to subtract from starting value
101
+     * @return difference between `baseValue` and `difference`
102
+     */
103
+    public float subtract(float baseValue, float difference) {
58 104
         return 0;
59 105
     }
60 106
 
61
-    //Subtract two doubles and return the answer
62
-    public double subtract(double x, double y){
107
+    /**
108
+     * @param baseValue  starting value
109
+     * @param difference value to subtract from starting value
110
+     * @return difference between `baseValue` and `difference`
111
+     */
112
+    public double subtract(double baseValue, double difference) {
63 113
         return 0;
64 114
     }
65 115
 
66
-    //Divide two ints and return the answer
67
-    public int divide(int x, int y){
116
+
117
+    /**
118
+     * @param dividend value to be divided
119
+     * @param divisor value to divide by
120
+     * @return division of `dividend` by `divisor
121
+     */
122
+    public int divide(int dividend, int divisor) {
68 123
         return 0;
69 124
     }
70 125
 
71
-    //Divide two long's and return the answer
72
-    public long divide(long x, long y){
126
+    /**
127
+     * @param dividend value to be divided
128
+     * @param divisor value to divide by
129
+     * @return division of `dividend` by `divisor
130
+     */
131
+    public long divide(long dividend, long divisor) {
73 132
         return 0;
74 133
     }
75 134
 
76
-    //Divide two short's and return the answer Must Type Cast
77
-    public short divide(short x, short y){
135
+    /**
136
+     * @param dividend value to be divided
137
+     * @param divisor value to divide by
138
+     * @return division of `dividend` by `divisor
139
+     */
140
+    public short divide(short dividend, short divisor) {
78 141
         return 0;
79 142
     }
80
-    //Divide two bytes and return the answer, Must Type Cast
81
-    public byte divide(byte x, byte y){
143
+
144
+    /**
145
+     * @param dividend value to be divided
146
+     * @param divisor value to divide by
147
+     * @return division of `dividend` by `divisor
148
+     */
149
+    public byte divide(byte dividend, byte divisor) {
82 150
         return 0;
83 151
     }
84 152
 
85
-    //Divide two floats and return the answer
86
-    public float divide(float x, float y){
153
+    /**
154
+     * @param dividend value to be divided
155
+     * @param divisor value to divide by
156
+     * @return division of `dividend` by `divisor
157
+     */
158
+    public float divide(float dividend, float divisor) {
87 159
         return 0;
88 160
     }
89 161
 
90
-    //Divide two doubles and return the answer
91
-    public double divide(double x, double y){
162
+    /**
163
+     * @param dividend value to be divided
164
+     * @param divisor value to divide by
165
+     * @return division of `dividend` by `divisor
166
+     */
167
+    public double divide(double dividend, double divisor) {
92 168
         return 0;
93 169
     }
94 170
 
95
-    //Multiply two ints and return the answer
96
-    public int multiply(int x, int y){
171
+
172
+    /**
173
+     * @param multiplicand value to be multiplied
174
+     * @param multiplier value to multiply by
175
+     * @return product of `multiplicand` by `multiplier`
176
+     */
177
+    public int multiply(int multiplicand, int multiplier) {
97 178
         return 0;
98 179
     }
99 180
 
100
-    //Multiply two long's and return the answer
101
-    public long multiply(long x, long y){
181
+    /**
182
+     * @param multiplicand value to be multiplied
183
+     * @param multiplier value to multiply by
184
+     * @return product of `multiplicand` by `multiplier`
185
+     */
186
+    public long multiply(long multiplicand, long multiplier) {
102 187
         return 0;
103 188
     }
104 189
 
105
-    //Multiply two short's and return the answer Must Type Cast
106
-    public short multiply(short x, short y){
190
+    /**
191
+     * @param multiplicand value to be multiplied
192
+     * @param multiplier value to multiply by
193
+     * @return product of `multiplicand` by `multiplier`
194
+     */
195
+    public short multiply(short multiplicand, short multiplier) {
107 196
         return 0;
108 197
     }
109
-    //Multiply two bytes and return the answer, Must Type Cast
110
-    public byte multiply(byte x, byte y){
198
+    /**
199
+     * @param multiplicand value to be multiplied
200
+     * @param multiplier value to multiply by
201
+     * @return product of `multiplicand` by `multiplier`
202
+     */
203
+    public byte multiply(byte multiplicand, byte multiplier) {
111 204
         return 0;
112 205
     }
113 206
 
114
-    //Multiply two floats and return the answer
115
-    public float multiply(float x, float y){
207
+    /**
208
+     * @param multiplicand value to be multiplied
209
+     * @param multiplier value to multiply by
210
+     * @return product of `multiplicand` by `multiplier`
211
+     */
212
+    public float multiply(float multiplicand, float multiplier) {
116 213
         return 0;
117 214
     }
118 215
 
119
-    //Multiply two doubles and return the answer
120
-    public double multiply(double x, double y){
216
+    /**
217
+     * @param multiplicand value to be multiplied
218
+     * @param multiplier value to multiply by
219
+     * @return product of `multiplicand` by `multiplier`
220
+     */
221
+    public double multiply(double multiplicand, double multiplier) {
121 222
         return 0;
122 223
     }
123 224
 
124
-    //Return true
125
-    public boolean returnTrue(){
225
+
226
+    /**
227
+      * @return true
228
+     */
229
+    public boolean returnTrue() {
126 230
         return false;
127 231
     }
128 232
 
129
-    //Return false
130
-    public boolean returnFalse(){
233
+    /**
234
+     * @return false
235
+     */
236
+    public boolean returnFalse() {
131 237
         return true;
132 238
     }
133 239
 

+ 55
- 0
src/main/java/com/zipcodewilmington/danny_do_better/StringUtilities.java Целия файл

@@ -0,0 +1,55 @@
1
+package com.zipcodewilmington.danny_do_better;
2
+
3
+/**
4
+ * Created by dan on 6/14/17.
5
+ */
6
+public class StringUtilities {
7
+
8
+    // Return the concatenation of two strings, `firstSegment`, and `secondSegment`
9
+    public String concatenation(String firstSegment, String secondSegment){
10
+        return null;
11
+    }
12
+
13
+    // Return the concatenation of an integer and a string, `firstSegment`, and `secondSegment`
14
+    public String concatenation(int firstSegment, String secondSegment){
15
+        return null;
16
+    }
17
+
18
+    // Return a substring of the first three characters of a string
19
+    public String getPrefix(String input){
20
+        return null;
21
+    }
22
+
23
+    // Return a substring of the last three characters of a string
24
+    public String getSuffix(String input){
25
+        return null;
26
+    }
27
+
28
+    // Return the equivalence of two strings as a boolean
29
+    public boolean compareTwoStrings(String inputValue, String comparableValue){
30
+        return false;
31
+    }
32
+
33
+    // Return the center character of a provided string
34
+    public Character getMiddleCharacter(String input){
35
+        int length = input.length();
36
+        int centerIndex = length /2;
37
+        char centerCharacter = input.charAt(centerIndex);
38
+        return centerCharacter;
39
+    }
40
+
41
+    // Return the first word of a string delimited by spaces.
42
+    public String getFirstWord(String spaceDelimitedString){
43
+        return null;
44
+    }
45
+
46
+    // Return the second word of a string delimited by spaces.
47
+    public String getTheSecondWord(String spaceDelimitedString){
48
+        return null;
49
+    }
50
+
51
+    // Return an identical string with characters in reverse order.
52
+    public String reverseTheTwo(String stringToReverse){
53
+        return null;
54
+    }
55
+}

+ 0
- 58
src/main/java/com/zipcodewilmington/danny_do_better/Strings.java Целия файл

@@ -1,58 +0,0 @@
1
-package com.zipcodewilmington.danny_do_better;
2
-
3
-/**
4
- * Created by dan on 6/14/17.
5
- */
6
-public class Strings {
7
-
8
-    //Concatenate two strings together that are passed in the parameters
9
-    public String concatenation(String one, String two){
10
-        return null;
11
-    }
12
-
13
-    //Concatenate a string and a integer together that are passed in the parameters
14
-    public String concatenation(int one, String two){
15
-        return null;
16
-    }
17
-
18
-    //Get the substring of the first three letters of a string
19
-    public String subStringBegin(String input){
20
-        return null;
21
-    }
22
-
23
-    //Get the substring of a string "Hello" so it returns the last three letters only
24
-    public String subStringEnd(String input){
25
-        return null;
26
-    }
27
-
28
-    //Compare the two strings using compareTo() and if they are return true, else false
29
-    public boolean compareTwoStrings(String one, String two){
30
-        return false;
31
-    }
32
-
33
-    //Compare the two strings using equals() and if they are return true, else false
34
-    public boolean compareTwoStringsEqual(String one, String two){
35
-        return false;
36
-    }
37
-
38
-    //Write a method that returns the middle character in the given string hint: use the .length and .charAt methods
39
-    public char getTheMiddleChar(String string){
40
-        return ' ';
41
-    }
42
-
43
-    //Use the indexOf method to find the first space in a string and .substring() to return the first word
44
-    public String getTheFirstWord(String string){
45
-        return null;
46
-    }
47
-
48
-    //Use the same behavior to find the second word
49
-    public String getTheSecondWord(String string){
50
-        return null;
51
-    }
52
-
53
-    //Create a method that uses the above methods to return a string consisting of the second and first word in reversed order
54
-    public String reverseTheTwo(String string){
55
-        return null;
56
-    }
57
-
58
-}

+ 83
- 21
src/test/java/com/zipcodewilmington/danny_do_better/MathUtilitiesTest.java Целия файл

@@ -7,58 +7,120 @@ import static org.junit.Assert.*;
7 7
  * Created by dan on 6/14/17.
8 8
  */
9 9
 public class MathUtilitiesTest {
10
+    private static volatile MathUtilities math = new MathUtilities();
10 11
 
12
+    @Test
13
+    public void testRemainder1(){
14
+        // : Given
15
+        Integer dividend = 7;
16
+        Integer divisor = 3;
17
+        Integer expected = 1;
11 18
 
12
-    MathUtilities math;
19
+        // : When
20
+        Integer actual = math.remainder(dividend, divisor);
13 21
 
14
-    @Before public void initialize(){
15
-        math = new MathUtilities();
22
+        // : Then
23
+        assertEquals(expected, actual);
16 24
     }
17 25
 
26
+
18 27
     @Test
19
-    public void testRemainder(){
20
-        Integer dividend = 7;
28
+    public void testRemainder2(){
29
+        // : Given
30
+        Integer dividend = 8;
21 31
         Integer divisor = 3;
22
-        Integer expected = 1;
32
+        Integer expected = 2;
23 33
 
24
-        Integer actual = this.math.remainder(dividend, divisor);
34
+        // : When
35
+        Integer actual = math.remainder(dividend, divisor);
25 36
 
26
-        assertTrue(expected == actual);
37
+        // : Then
38
+        assertEquals(expected, actual);
27 39
     }
28 40
 
29 41
     @Test
30
-    public void testGreaterThan(){
31
-        assertTrue(this.math.isGreaterThan(456,23));
42
+    public void testGreaterThanTrue(){
43
+        // : Given
44
+        int greaterValue = 450;
45
+        int lesserValue = 350;
46
+
47
+
48
+        // : When
49
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
50
+
51
+        // : Then
52
+        assertTrue(outcome);
32 53
     }
33 54
 
55
+
34 56
     @Test
35
-    public void testLessThan(){
36
-        assertTrue(this.math.isLessThan(1 ,3));
57
+    public void testGreaterThanFalse(){
58
+        // : Given
59
+        int greaterValue = 350;
60
+        int lesserValue = 350;
61
+
62
+        // : When
63
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
64
+
65
+        // : Then
66
+        assertTrue(outcome);
37 67
     }
38 68
 
69
+
70
+    @Test
71
+    public void testLessThanTrue(){
72
+        // : Given
73
+        int greaterValue = 450;
74
+        int lesserValue = 350;
75
+
76
+
77
+        // : When
78
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
79
+
80
+        // : Then
81
+        assertFalse(outcome);
82
+    }
83
+
84
+
85
+
86
+    @Test
87
+    public void testLessThan1(){
88
+        // : Given
89
+        int greaterValue = 450;
90
+        int lesserValue = 350;
91
+
92
+
93
+        // : When
94
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
95
+
96
+        // : Then
97
+        assertTrue(outcome);
98
+    }
99
+
100
+
39 101
     @Test
40 102
     public void testLessOrEqual(){
41
-        assertTrue(this.math.isLessThanOrEqualTo(3 , 3));
42
-        assertTrue(this.math.isLessThanOrEqualTo(3, 6));
103
+        assertTrue(math.isLessThanOrEqualTo(3 , 3));
104
+        assertTrue(math.isLessThanOrEqualTo(3, 6));
43 105
     }
44 106
 
45 107
     @Test
46 108
     public void testGreaterOrEqual(){
47
-        assertTrue(this.math.isGreaterThanOrEqualTo(4, 4));
48
-        assertTrue(this.math.isGreaterThanOrEqualTo(78, 5));
109
+        assertTrue(math.isGreaterThanOrEqualTo(4, 4));
110
+        assertTrue(math.isGreaterThanOrEqualTo(78, 5));
49 111
     }
50 112
 
51 113
     @Test
52 114
     public void testLogicalAnd(){
53
-        assertTrue(this.math.isBoth(3));
54
-        assertFalse(this.math.isBoth(4));
115
+        assertTrue(math.isBoth(3));
116
+        assertFalse(math.isBoth(4));
55 117
     }
56 118
 
57 119
     @Test
58 120
     public void testLogicalOr(){
59
-        assertTrue(this.math.logicalOr(4));
60
-        assertTrue(this.math.logicalOr(14564));
61
-        assertFalse(this.math.logicalOr(54));
121
+        assertTrue(math.logicalOr(4));
122
+        assertTrue(math.logicalOr(14564));
123
+        assertFalse(math.logicalOr(54));
62 124
     }
63 125
 
64 126
 

+ 203
- 73
src/test/java/com/zipcodewilmington/danny_do_better/PrimativeTypesTest.java Целия файл

@@ -1,136 +1,266 @@
1 1
 package com.zipcodewilmington.danny_do_better;
2 2
 
3
-import com.zipcodewilmington.danny_do_better.PrimativeTypes;
4
-import org.junit.Before;
5 3
 import org.junit.Test;
4
+
6 5
 import static org.junit.Assert.*;
7 6
 /**
8 7
  * Created by dan on 6/14/17.
9 8
  */
10 9
 public class PrimativeTypesTest {
10
+    private PrimativeTypes primativeTypes = new PrimativeTypes();
11 11
 
12
-    PrimativeTypes primativeTypes;
12
+    @Test
13
+    public void testAdditions() {
14
+        int baseValue = 20;
15
+        int addedValue = 7;
16
+        int expected = 27;
17
+        int actual = primativeTypes.add(baseValue, addedValue);
18
+        assertEquals(expected,actual);
19
+    }
20
+    @Test
21
+    public void testAdditions1() {
22
+        long baseValue = 228437266;
23
+        long difference = 228437265;
24
+        long expected = 456874531;
25
+        long actual = primativeTypes.add(baseValue, difference);
26
+        assertEquals(expected,actual);
27
+    }
28
+    @Test
29
+    public void testAdditions2() {
30
+        short baseValue = 16384;
31
+        short addedValue = 7;
32
+        short expected = 32767;
33
+        short actual = primativeTypes.add(baseValue, addedValue);
34
+        assertEquals(expected,actual);
35
+    }
13 36
 
14
-    @Before public void initialize(){
15
-        primativeTypes = new PrimativeTypes();
37
+    @Test
38
+    public void testAdditions4() {
39
+        byte baseValue = 63;
40
+        byte addedValue = 64;
41
+        byte expected = 127;
42
+        byte actual = primativeTypes.add(baseValue, addedValue);
43
+        assertEquals(expected,actual);
44
+    }
45
+    @Test
46
+    public void testAdditions5() {
47
+        float baseValue = 750.585F;
48
+        float addedValue = 795.000F;
49
+        float expected = 1545.585F;
50
+        float actual = primativeTypes.add(baseValue, addedValue);
51
+        assertEquals(expected,actual, 0);
16 52
     }
17 53
 
18 54
     @Test
19
-    public void testAdditions(){
20
-        int expectedInt = 27;
21
-        int actualInt = this.primativeTypes.add(20,7);
55
+    public void testAdditions6() {
56
+        double baseValue = 225.25;
57
+        double addedValue = 231;
58
+        double expected = 456.25;
59
+        double actual = primativeTypes.add(baseValue,addedValue);
60
+        assertEquals(expected,actual, 0);
61
+    }
62
+
63
+
22 64
 
23
-        long expectedLong = 456874531;
24
-        long actualLong = this.primativeTypes.add(228437266, 228437265);
25 65
 
26
-        short expectedShort = 32767;
27
-        short actualShort = (short) this.primativeTypes.add(16384, 16383);
28 66
 
29
-        byte expectedByte = 127;
30
-        byte actualByte = (byte) this.primativeTypes.add(63, 64);
31 67
 
32
-        float expectedFloat = (float) 1545.585;
33
-        float actualFloat = (float) this.primativeTypes.add(750.585,795.000);
34 68
 
35
-        double expectedDouble = 456.25;
36
-        double actualDouble = this.primativeTypes.add(225.25,231);
37 69
 
38
-        assertEquals(expectedInt,actualInt);
39
-        assertEquals(expectedLong,actualLong);
40
-        assertEquals(expectedShort,actualShort);
41
-        assertEquals(expectedByte,actualByte);
42
-        assertEquals(expectedFloat,actualFloat, 0);
43
-        assertEquals(expectedDouble,actualDouble, 0);
44
-    }
45 70
 
46
-    @Test
47
-    public void testSubtractions(){
48
-        int expectedInt = 13;
49
-        int actualInt = this.primativeTypes.subtract(20,7);
50 71
 
51
-        long expectedLong = 1;
52
-        long actualLong = this.primativeTypes.subtract(228437266, 228437265);
53 72
 
54
-        short expectedShort = 1;
55
-        short actualShort = (short) this.primativeTypes.subtract(16384, 16383);
56 73
 
57
-        byte expectedByte = -1;
58
-        byte actualByte = (byte) this.primativeTypes.subtract(63, 64);
59 74
 
60
-        float expectedFloat = (float) -44.415;
61
-        float actualFloat = (float) this.primativeTypes.subtract(750.585,795.000);
62 75
 
63
-        double expectedDouble = -5.75;
64
-        double actualDouble = this.primativeTypes.subtract(225.25,231);
65 76
 
77
+
78
+    @Test
79
+    public void testSubtractions(){
80
+        int baseValue = 20;
81
+        int difference = 7;
82
+        int expectedInt = 13;
83
+        int actualInt = primativeTypes.subtract(baseValue,difference);
66 84
         assertEquals(expectedInt,actualInt);
85
+    }
86
+    @Test
87
+    public void testSubtractions1() {
88
+        long baseValue = 228437266;
89
+        long difference = 228437265;
90
+        long expectedLong = 1;
91
+        long actualLong = primativeTypes.subtract(baseValue, difference);
67 92
         assertEquals(expectedLong,actualLong);
93
+    }
94
+    @Test
95
+    public void testSubtractions2() {
96
+        short baseValue = 16384;
97
+        short difference = 16383;
98
+        short expectedShort = 1;
99
+        short actualShort = (short) primativeTypes.subtract(baseValue, difference);
68 100
         assertEquals(expectedShort,actualShort);
101
+    }
102
+    @Test
103
+    public void testSubtractions3() {
104
+        byte baseValue = 63;
105
+        byte difference = 64;
106
+        byte expectedByte = -1;
107
+        byte actualByte = primativeTypes.subtract(baseValue, difference);
69 108
         assertEquals(expectedByte,actualByte);
109
+    }
110
+    @Test
111
+    public void testSubtractions4() {
112
+        float baseValue = 750.585F;
113
+        float difference = 795.0F;
114
+        float expectedFloat = (float) -44.415;
115
+        float actualFloat = (float) primativeTypes.subtract(baseValue,difference);
70 116
         assertEquals(expectedFloat,actualFloat, 0);
117
+    }
118
+    @Test
119
+    public void testSubtractions5() {
120
+        double baseValue = 225.25;
121
+        double difference = 231;
122
+        double expectedDouble = -5.75;
123
+        double actualDouble = primativeTypes.subtract(baseValue, difference);
71 124
         assertEquals(expectedDouble,actualDouble, 0);
72 125
     }
73 126
 
74
-    @Test
75
-    public void testDivision(){
76
-        int expectedInt = 10;
77
-        int actualInt = this.primativeTypes.divide(20,2);
78 127
 
79
-        long expectedLong = 20000;
80
-        long actualLong = this.primativeTypes.divide(20000000, 1000);
81 128
 
82
-        short expectedShort = 2;
83
-        short actualShort = (short) this.primativeTypes.divide(2, 1);
84 129
 
85
-        byte expectedByte = 2;
86
-        byte actualByte = (byte) this.primativeTypes.divide(64, 32);
87 130
 
88
-        float expectedFloat = (float) 2.50;
89
-        float actualFloat = (float) this.primativeTypes.divide(7.5,3);
90 131
 
91
-        double expectedDouble = 1.25;
92
-        double actualDouble = this.primativeTypes.divide(5.0,4.0);
93 132
 
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+    @Test
141
+    public void testDivision(){
142
+        int dividend = 20;
143
+        int divisor = 2;
144
+        int expectedInt = 10;
145
+        int actualInt = primativeTypes.divide(dividend, divisor);
94 146
         assertEquals(expectedInt,actualInt);
147
+    }
148
+    @Test
149
+    public void testDivision1() {
150
+        int dividend = 20000000;
151
+        int divisor = 1000;
152
+        long expectedLong = 20000;
153
+        long actualLong = primativeTypes.divide(dividend, divisor);
95 154
         assertEquals(expectedLong,actualLong);
155
+    }
156
+    @Test
157
+    public void testDivision2() {
158
+        short dividend = 2;
159
+        short divisor = 1;
160
+        short expectedShort = 2;
161
+        short actualShort = primativeTypes.divide(dividend, divisor);
96 162
         assertEquals(expectedShort,actualShort);
163
+
164
+    }
165
+    @Test
166
+    public void testDivision3() {
167
+        byte dividend = 64;
168
+        byte divisor = 32;
169
+        byte expectedByte = 2;
170
+        byte actualByte = (byte) primativeTypes.divide(dividend, divisor);
97 171
         assertEquals(expectedByte,actualByte);
172
+    }
173
+    @Test
174
+    public void testDivision4() {
175
+        float dividend = 7.5F;
176
+        float divisor = 3;
177
+        float expectedFloat = 2.50F;
178
+        float actualFloat = primativeTypes.divide(dividend,divisor);
98 179
         assertEquals(expectedFloat,actualFloat, 0);
180
+    }
181
+    @Test
182
+    public void testDivision5() {
183
+        double dividend = 5.0;
184
+        double divisor = 4.0;
185
+        double expectedDouble = 1.25;
186
+        double actualDouble = primativeTypes.divide(dividend,divisor);
99 187
         assertEquals(expectedDouble,actualDouble, 0);
100 188
     }
101 189
 
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
102 207
     @Test
103 208
     public void testMultiplication(){
209
+        int multiplicand = 5;
210
+        int multiplier = 2;
104 211
         int expectedInt = 10;
105
-        int actualInt = this.primativeTypes.multiply(5,2);
106
-
212
+        int actualInt = primativeTypes.multiply(multiplicand,multiplier);
213
+        assertEquals(expectedInt,actualInt);
214
+    }
215
+    @Test
216
+    public void testMultiplication1() {
217
+        long multiplicand = 20;
218
+        long multiplier = 1000;
107 219
         long expectedLong = 20000;
108
-        long actualLong = this.primativeTypes.multiply(20, 1000);
109
-
220
+        long actualLong = primativeTypes.multiply(multiplicand, multiplier);
221
+        assertEquals(expectedLong, actualLong);
222
+    }
223
+    @Test
224
+    public void testMultiplication2() {
225
+        short multiplicand = 2;
226
+        short multiplier = 1;
110 227
         short expectedShort = 2;
111
-        short actualShort = (short) this.primativeTypes.multiply(2, 1);
112
-
228
+        short actualShort = (short) primativeTypes.multiply(multiplicand, multiplier);
229
+        assertEquals(expectedShort, actualShort);
230
+    }
231
+    @Test
232
+    public void testMultiplication3() {
233
+        byte multiplicand = 16;
234
+        byte multiplier = 14;
113 235
         byte expectedByte = 64;
114
-        byte actualByte = (byte) this.primativeTypes.multiply(16, 4);
115
-
236
+        byte actualByte = (byte) primativeTypes.multiply(multiplicand, multiplier);
237
+        assertEquals(expectedByte, actualByte);
238
+    }
239
+    @Test
240
+    public void testMultiplication4() {
241
+        float multiplicand = 2.5F;
242
+        float multiplier = 1;
116 243
         float expectedFloat = (float) 2.50;
117
-        float actualFloat = (float) this.primativeTypes.multiply(2.50,1);
118
-
244
+        float actualFloat = (float) primativeTypes.multiply(multiplicand,multiplier);
245
+        assertEquals(expectedFloat, actualFloat, 0);
246
+    }
247
+    @Test
248
+    public void testMultiplication5() {
249
+        double multiplicand = 3.25;
250
+        double multiplier = 3.0;
119 251
         double expectedDouble = 9.75;
120
-        double actualDouble = this.primativeTypes.multiply(3.25,3.0);
252
+        double actualDouble = primativeTypes.multiply(multiplicand,multiplier);
253
+        assertEquals(expectedDouble, actualDouble, 0);
254
+    }
121 255
 
122
-        assertEquals(expectedInt,actualInt);
123
-        assertEquals(expectedLong,actualLong);
124
-        assertEquals(expectedShort,actualShort);
125
-        assertEquals(expectedByte,actualByte);
126
-        assertEquals(expectedFloat,actualFloat, 0);
127
-        assertEquals(expectedDouble,actualDouble, 0);
256
+    @Test
257
+    public void testReturnTrue(){
258
+        assertTrue(primativeTypes.returnTrue());
128 259
     }
129 260
 
130 261
     @Test
131
-    public void testBoolean(){
132
-        assertTrue(this.primativeTypes.returnTrue());
133
-        assertFalse(this.primativeTypes.returnFalse());
262
+    public void testReturnFalse(){
263
+        assertFalse(primativeTypes.returnFalse());
134 264
     }
135 265
 
136 266
 }

+ 166
- 0
src/test/java/com/zipcodewilmington/danny_do_better/StringUtilitiesTest.java Целия файл

@@ -0,0 +1,166 @@
1
+package com.zipcodewilmington.danny_do_better;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import static org.junit.Assert.*;
7
+
8
+/**
9
+ * Created by dan on 6/14/17.
10
+ */
11
+public class StringUtilitiesTest {
12
+    private static StringUtilities stringUtilities = new StringUtilities();
13
+
14
+    @Test
15
+    public void concatenationStringTest(){
16
+        // : Given
17
+        String one = "Hello";
18
+        String two = " Java";
19
+        String expected = "Hello Java";
20
+
21
+        // : When
22
+        String actual = stringUtilities.concatenation(one,two);
23
+
24
+
25
+        // : Then
26
+        assertEquals(expected, actual);
27
+    }
28
+
29
+
30
+    @Test
31
+    public void concatenationStringAndIntegerTest(){
32
+        // : Given
33
+        int one = 1;
34
+        String two = " Java";
35
+        String expected = "1 Java";
36
+
37
+        // : When
38
+        String actual = stringUtilities.concatenation(one,two);
39
+
40
+
41
+        // : Then
42
+        assertEquals(expected, actual);
43
+    }
44
+
45
+    @Test
46
+    public void substringBeginTest(){
47
+        // : Given
48
+        String input = "Hello";
49
+        String expected = "olleH";
50
+
51
+        // : When
52
+        String actual = stringUtilities.getPrefix(input);
53
+
54
+        // : Then
55
+        assertEquals(expected, actual);
56
+    }
57
+
58
+    @Test
59
+    public void substringEndTest(){
60
+        // : Given
61
+        String input = "Hello";
62
+        String expected = "llo";
63
+
64
+        // : When
65
+        String actual = stringUtilities.getSuffix("Hello");
66
+
67
+        // : Then
68
+        assertEquals(expected, actual);
69
+    }
70
+
71
+    @Test
72
+    public void compareToTestEquals(){
73
+        // : Given
74
+        String inputValue = "Zipcode";
75
+        String comparableValue = "Zipcode";
76
+
77
+        // : When
78
+        boolean actual = stringUtilities.compareTwoStrings(inputValue, comparableValue);
79
+
80
+        // : Then
81
+        assertTrue(actual);
82
+    }
83
+
84
+
85
+    @Test
86
+    public void compareToTestNotEquals(){
87
+        // : Given
88
+        String inputValue = "Zipcode";
89
+        String comparableValue = "Zipcodee";
90
+
91
+        // : When
92
+        boolean actual = stringUtilities.compareTwoStrings(inputValue, comparableValue);
93
+
94
+        // : Then
95
+        assertFalse(actual);
96
+    }
97
+
98
+    @Test
99
+    public void getTheMiddleChar(){
100
+        // : Given
101
+        String input = "Zipcode";
102
+        char expected = 'c';
103
+
104
+        // : When
105
+        char actual = stringUtilities.getMiddleCharacter(input);
106
+
107
+        // : Then
108
+        Assert.assertEquals(expected, actual);
109
+    }
110
+
111
+
112
+    @Test
113
+    public void getTheMiddleCharr(){
114
+        // : Given
115
+        String input = "Zipcoder";
116
+        Character expected = 'c';
117
+
118
+        // : When
119
+        Character actual = stringUtilities.getMiddleCharacter(input);
120
+
121
+        // : Then
122
+        Assert.assertEquals(expected.toString(), actual.toString());
123
+    }
124
+
125
+
126
+    @Test
127
+    public void getTheFirstWord(){
128
+        // : Given
129
+        String input = "Zipcode Wilmington";
130
+        String expected = "Zipcode";
131
+
132
+        // : When
133
+        String actual = stringUtilities.getFirstWord(input);
134
+
135
+        // : Then
136
+        assertEquals(expected, actual);
137
+    }
138
+
139
+
140
+    @Test
141
+    public void getTheSecondWord(){
142
+        // : Given
143
+        String input = "Zipcode Wilmington";
144
+        String expected = "Wilmington";
145
+
146
+        // : When
147
+        String actual = stringUtilities.getFirstWord(input);
148
+
149
+        // : Then
150
+        assertEquals(expected, actual);
151
+    }
152
+
153
+    @Test
154
+    public void reverseThem(){
155
+        // : Given
156
+        String input = "Zipcode Wilmington";
157
+        String expected = "notgnimliW edocpiZ";
158
+
159
+
160
+        // : When
161
+        String actual = stringUtilities.reverseTheTwo(input);
162
+
163
+        // : Then
164
+        assertEquals(expected, actual);
165
+    }
166
+}

+ 0
- 82
src/test/java/com/zipcodewilmington/danny_do_better/StringsTest.java Целия файл

@@ -1,82 +0,0 @@
1
-package com.zipcodewilmington.danny_do_better;
2
-
3
-import com.zipcodewilmington.danny_do_better.Strings;
4
-import org.junit.Before;
5
-import org.junit.Test;
6
-import static org.junit.Assert.*;
7
-
8
-/**
9
- * Created by dan on 6/14/17.
10
- */
11
-public class StringsTest {
12
-
13
-    Strings strings;
14
-
15
-    @Before public void initialize(){
16
-        strings = new Strings();
17
-    }
18
-
19
-    @Test
20
-    public void concatenationStringTest(){
21
-        String one = "Hello", two = " Java";
22
-        assertTrue(this.strings.concatenation(one,two).equals("Hello Java"));
23
-    }
24
-
25
-    @Test
26
-    public void concatenationStringAndIntegerTest(){
27
-        int one = 21;
28
-        String two = " Years Old";
29
-        assertTrue(this.strings.concatenation(one, two).equals("21 Years Old"));
30
-    }
31
-
32
-    @Test
33
-    public void substringBeginTest(){
34
-        String string = "Hello";
35
-        assertTrue(this.strings.subStringBegin(string).equals("Hel"));
36
-    }
37
-
38
-    @Test
39
-    public void substringEndTest(){
40
-        String string = "Hello";
41
-        assertTrue(this.strings.subStringEnd(string).equals("llo"));
42
-    }
43
-
44
-    @Test
45
-    public void compareToTest(){
46
-        String one = "Zipcode", two = "Zipcode", three ="Wilmington";
47
-        assertTrue(this.strings.compareTwoStrings(one,two));
48
-        assertFalse(this.strings.compareTwoStrings(one,three));
49
-    }
50
-
51
-    @Test
52
-    public void equalToTest(){
53
-        String one = "Zipcode", two = "Zipcode", three = "Wilmington";
54
-        assertTrue(this.strings.compareTwoStringsEqual(one, two));
55
-        assertFalse(this.strings.compareTwoStringsEqual(three, two));
56
-    }
57
-
58
-    @Test
59
-    public void getTheMiddleChar(){
60
-        String one = "Zipcode";
61
-        assertTrue('c' == this.strings.getTheMiddleChar(one));
62
-    }
63
-
64
-    @Test
65
-    public void getTheFirstWord(){
66
-        String string = "Zipcode Wilmington";
67
-        assertTrue(this.strings.getTheFirstWord(string).equals("Zipcode"));
68
-    }
69
-
70
-    @Test
71
-    public void getTheSecondWord(){
72
-        String string = "Zipcode Wilmington";
73
-        assertTrue(this.strings.getTheSecondWord(string).equals("Wilmington"));
74
-    }
75
-
76
-    @Test
77
-    public void reverseThem(){
78
-        String string = "Zipcode Wilmington";
79
-        assertTrue(this.strings.reverseTheTwo(string).equals("Wilmington Zipcode"));
80
-    }
81
-
82
-}

BIN
target/classes/HelloWorld/HelloWorld.class Целия файл


BIN
target/classes/Math/Math.class Целия файл


BIN
target/classes/PrimativeTypes/PrimativeTypes.class Целия файл


BIN
target/classes/Strings/Strings.class Целия файл


BIN
target/classes/Variables/Variables.class Целия файл


BIN
target/classes/com/zipcodewilmington/danny_do_better/HelloWorld.class Целия файл


BIN
target/classes/com/zipcodewilmington/danny_do_better/MathUtilities.class Целия файл


BIN
target/classes/com/zipcodewilmington/danny_do_better/PrimativeTypes.class Целия файл


BIN
target/classes/com/zipcodewilmington/danny_do_better/StringUtilities.class Целия файл


BIN
target/test-classes/HelloWorld/HelloWorldTest.class Целия файл


BIN
target/test-classes/Math/MathTest.class Целия файл


BIN
target/test-classes/PrimativeTypes/PrimativeTypesTest.class Целия файл


BIN
target/test-classes/Strings/StringsTest.class Целия файл


BIN
target/test-classes/Variables/VariablesTest.class Целия файл


BIN
target/test-classes/com/zipcodewilmington/danny_do_better/HelloWorldTest.class Целия файл


BIN
target/test-classes/com/zipcodewilmington/danny_do_better/MathUtilitiesTest.class Целия файл


BIN
target/test-classes/com/zipcodewilmington/danny_do_better/PrimativeTypesTest.class Целия файл


BIN
target/test-classes/com/zipcodewilmington/danny_do_better/StringUtilitiesTest.class Целия файл