forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveElementTest.java
More file actions
36 lines (29 loc) · 982 Bytes
/
RemoveElementTest.java
File metadata and controls
36 lines (29 loc) · 982 Bytes
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
package com.examplehub.leetcode.easy;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class RemoveElementTest {
@Test
void testSolution1() {
int[] ints = new int[] {3, 2, 2, 3};
assertEquals(2, RemoveElement.solution1(ints, 3));
assertTrue(ints[0] == 2 && ints[1] == 2);
ints = new int[] {0, 1, 2, 2, 3, 0, 4, 2};
assertEquals(5, RemoveElement.solution1(ints, 2));
int[] newInts = {0, 1, 3, 0, 4};
for (int i = 0; i < newInts.length; i++) {
assertEquals(ints[i], newInts[i]);
}
}
@Test
void testSolution2() {
int[] ints = new int[] {3, 2, 2, 3};
assertEquals(2, RemoveElement.solution2(ints, 3));
assertTrue(ints[0] == 2 && ints[1] == 2);
ints = new int[] {0, 1, 2, 2, 3, 0, 4, 2};
assertEquals(5, RemoveElement.solution2(ints, 2));
int[] newInts = {0, 1, 3, 0, 4};
for (int i = 0; i < newInts.length; i++) {
assertEquals(ints[i], newInts[i]);
}
}
}