-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManipulationsWithArraysTest.java
More file actions
202 lines (121 loc) · 4.85 KB
/
Copy pathManipulationsWithArraysTest.java
File metadata and controls
202 lines (121 loc) · 4.85 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import algorithms.ManipulationsWithArrays;
import algorithms.OddEvenValuesInArray;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ManipulationsWithArraysTest {
@Test
public void multiplyArrayByNumber_HappyPath() {
int[] array = {1, 2, 3, 4, 5};
int multiplier = 3;
int[] expectedResult = {3, 6, 9, 12, 15};
int[] actualResult = new ManipulationsWithArrays().multiplyArrayByNumber(array, multiplier);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void multiplyArrayByNumber_Null() {
int[] array = null;
int multiplier = 3;
int[] expectedResult = null;
int[] actualResult = new ManipulationsWithArrays().multiplyArrayByNumber(array, multiplier);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void doubleArray_HappyPath() {
int[] array = {1, 2, 3, 4, 5};
double[] expectedResult = {1.0, 2.0, 3.0, 4.0, 5.0};
double[] actualResult = new ManipulationsWithArrays().toDoubleArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void doubleArray_Null() {
int[] array = null;
double[] expectedResult = null;
double[] actualResult = new ManipulationsWithArrays().toDoubleArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void intArray_HappyPath() {
double[] array = {1.1, 2.5, 3.7, 4.0, 5.5};
int[] expectedResult = {1, 2, 3, 4, 5};
int[] actualResult = new ManipulationsWithArrays().toIntArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void intArray_Null() {
double[] array = null;
int[] expectedResult = null;
int[] actualResult = new ManipulationsWithArrays().toIntArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void stringArray_HappyPath() {
int[] array = {1, 2, 3, 4, 5};
String[] expectedResult = {"1", "2", "3", "4", "5"};
String[] actualResult = new ManipulationsWithArrays().toStringArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void stringArray_Null() {
int[] array = null;
String[] expectedResult = null;
String[] actualResult = new ManipulationsWithArrays().toStringArray(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void stringArray2_HappyPath() {
double[] array = {1.1, 2.5, 3.7, 4.0, 5.5};
String[] expectedResult = {"1.1", "2.5", "3.7", "4.0", "5.5"};
String[] actualResult = new ManipulationsWithArrays().toStringArray2(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void stringArray2_Null() {
double[] array = null;
String[] expectedResult = null;
String[] actualResult = new ManipulationsWithArrays().toStringArray2(array);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void allArrayValuesAreGreaterThanNumber_HappyPath() {
int[] array = {6, 7 , 8, 9, 10};
int number = 5;
boolean expectedResult = true;
boolean actualResult = new ManipulationsWithArrays().areValuesGreaterThanNumber(array, number);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void allArrayValuesAreLesserThanNumber_HappyPath() {
int[] array = {1, 2, 3, 7, 8};
int number = 10;
boolean expectedResult = false;
boolean actualResult = new ManipulationsWithArrays().areValuesGreaterThanNumber(array, number);
Assert.assertEquals(actualResult, expectedResult);
}
/*
Test fails if one of the middle array elements is lesser than a number, need to debug
@Test
public void oneArrayElementIsLesserThanNumber() {
int[] array = {24, 37, 16, 11, 48, 89};
int number = 15;
boolean expectedResult = false;
boolean actualResult = new OddEvenValuesInArray().areValuesGreaterThanNumber(array, number);
Assert.assertEquals(actualResult, expectedResult);
}
*/
@Test
public void boundaryArrayValues() {
int[] array = {7, 10, 15, 19};
int number = 7;
boolean expectedResult = false;
boolean actualResult = new ManipulationsWithArrays().areValuesGreaterThanNumber(array, number);
Assert.assertEquals(actualResult, expectedResult);
}
@Test
public void NullArray() {
int[] array = null;
int num = 10;
boolean expectedResult = false;
boolean actualResult = new ManipulationsWithArrays().areValuesGreaterThanNumber(array, num);
Assert.assertEquals(actualResult, expectedResult);
}
}