Skip to content

Commit 130894c

Browse files
committed
Replaced toString with values in unit tests.
1 parent a9e1b84 commit 130894c

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/test/java/g0001_0100/s0001_two_sum/SolutionTest.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
import static org.hamcrest.CoreMatchers.equalTo;
44
import static org.hamcrest.MatcherAssert.assertThat;
55

6-
import java.util.Arrays;
76
import org.junit.Test;
87

98
public class SolutionTest {
109
@Test
1110
public void twoSum() {
12-
assertThat(
13-
Arrays.toString(new Solution().twoSum(new int[] {2, 7, 11, 15}, 9)),
14-
equalTo("[0, 1]"));
11+
assertThat(new Solution().twoSum(new int[] {2, 7, 11, 15}, 9), equalTo(new int[] {0, 1}));
1512
}
1613
}

src/test/java/g0001_0100/s0015_three_sum/SolutionTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import static org.hamcrest.CoreMatchers.equalTo;
44
import static org.hamcrest.MatcherAssert.assertThat;
55

6+
import com_github_leetcode.ArrayUtils;
67
import org.junit.Test;
78

89
public class SolutionTest {
910
@Test
1011
public void threeSum() {
1112
assertThat(
12-
new Solution().threeSum(new int[] {-1, 0, 1, 2, -1, -4}).toString(),
13-
equalTo("[[-1, -1, 2], [-1, 0, 1]]"));
13+
new Solution().threeSum(new int[] {-1, 0, 1, 2, -1, -4}),
14+
equalTo(ArrayUtils.getLists(new int[][] {{-1, -1, 2}, {-1, 0, 1}})));
1415
}
1516
}

src/test/java/g0001_0100/s0018_four_sum/SolutionTest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import static org.hamcrest.CoreMatchers.equalTo;
44
import static org.hamcrest.MatcherAssert.assertThat;
55

6+
import com_github_leetcode.ArrayUtils;
67
import org.junit.Test;
78

89
public class SolutionTest {
910
@Test
1011
public void fourSum() {
1112
assertThat(
12-
new Solution().fourSum(new int[] {1, 0, -1, 0, -2, 2}, 0).toString(),
13-
equalTo("[[-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]]"));
13+
new Solution().fourSum(new int[] {1, 0, -1, 0, -2, 2}, 0),
14+
equalTo(
15+
ArrayUtils.getLists(
16+
new int[][] {{-2, -1, 1, 2}, {-2, 0, 0, 2}, {-1, 0, 0, 1}})));
1417
}
1518
}

src/test/java/g0001_0100/s0031_next_permutation/SolutionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class SolutionTest {
1010
public void nextPermutation() {
1111
int[] array = new int[] {1, 2, 3};
1212
new Solution().nextPermutation(array);
13-
assertThat(java.util.Arrays.toString(array), equalTo("[1, 3, 2]"));
13+
assertThat(array, equalTo(new int[] {1, 3, 2}));
1414
}
1515
}

0 commit comments

Comments
 (0)