-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathRemoveValueTest.java
More file actions
78 lines (56 loc) · 2.26 KB
/
RemoveValueTest.java
File metadata and controls
78 lines (56 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.zipcodewilmington.arrayutility;
import org.junit.Test;
/**
* Created by leon on 3/1/18.
* The purpose of this class is to thoroughly test the method removeValue()
*/
public class RemoveValueTest {
@Test
public void integerTest() {
// Given
Integer valueToRemove = 7;
Integer[] expected = {11, 2, 8, 4, 5, 0, 9, 8};
Integer[] inputArray = {11, 2, valueToRemove, 8, 4, 5, valueToRemove, 0, 9, 8, valueToRemove};
ArrayUtility<Integer> arrayUtility = new ArrayUtility<Integer>(inputArray);
// When
Integer[] actual = arrayUtility.removeValue(valueToRemove);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void longTest() {
// Given
Long valueToRemove = 7L;
Long[] expected = {12L, 2L, 8L, 4L, 5L, 0L, 9L, 8L};
Long[] inputArray = {12L, 2L, valueToRemove, 8L, 4L, 5L, valueToRemove, 0L, 9L, 8L, valueToRemove};
ArrayUtility<Long> arrayUtility = new ArrayUtility<Long>(inputArray);
// When
Long[] actual = arrayUtility.removeValue(valueToRemove);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void stringTest() {
// Given
String valueToRemove = "7";
String[] expected = {"13", "2", "8", "4", "5", "0", "9", "8"};
String[] inputArray = {"13", "2", valueToRemove, "8", "4", "5", valueToRemove, "0", "9", "8", valueToRemove};
ArrayUtility<String> arrayUtility = new ArrayUtility<String>(inputArray);
// When
String[] actual = arrayUtility.removeValue(valueToRemove);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
@Test
public void objectTest() {
// Given
Object valueToRemove = "7";
Object[] expected = {"41", "2", "8", "4", "5", "0", "9", "8"};
Object[] inputArray = {"41", "2", valueToRemove, "8", "4", "5", valueToRemove, "0", "9", "8", valueToRemove};
ArrayUtility<Object> arrayUtility = new ArrayUtility<Object>(inputArray);
// When
Object[] actual = arrayUtility.removeValue(valueToRemove);
// Then
UnitTestingUtils.assertArrayEquality(expected, actual);
}
}