Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improved unit tests.
  • Loading branch information
javadev committed Nov 23, 2021
commit f7ade8dc8a76ada1de5020ca8fcb7292dd17aabd
1 change: 0 additions & 1 deletion src/test/java/com_github_leetcode/ArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;

public class ArrayUtils {

private ArrayUtils() {}

public static List<List<Integer>> getLists(int[][] expected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class SolutionTest {
@Test
public void trappingRainWater() {
public void trap() {
assertThat(new Solution().trap(new int[] {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}), equalTo(6));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class SolutionTest {
@Test
public void multiplyStrings() {
public void multiply() {
assertThat(new Solution().multiply("2", "3"), equalTo("6"));
}
}
2 changes: 0 additions & 2 deletions src/test/java/g0001_0100/s0048_rotate_image/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ public class SolutionTest {
public void rotate() {
int[][] expected = new int[][] {{7, 4, 1}, {8, 5, 2}, {9, 6, 3}};
int[][] input = new int[][] {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

new Solution().rotate(input);

assertThat(input, equalTo(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public void groupAnagrams() {
expected.add(Arrays.asList("eat", "tea", "ate"));
expected.add(Arrays.asList("bat"));
expected.add(Arrays.asList("tan", "nat"));

List<List<String>> actual =
new Solution()
.groupAnagrams(new String[] {"eat", "tea", "tan", "ate", "nat", "bat"});

assertThat(actual, equalTo(expected));
}
}
2 changes: 1 addition & 1 deletion src/test/java/g0001_0100/s0050_powx_n/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class SolutionTest {
@Test
public void powxN() {
public void myPow() {
assertThat(new Solution().myPow(2.00000, 10), equalTo(1024.00000));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

public class SolutionTest {
@Test
public void mergeIntervals() {
public void merge() {
int[][] input = {{1, 3}, {2, 6}, {8, 10}, {15, 18}};
int[][] expected = {{1, 6}, {8, 10}, {15, 18}};
int[][] actual = new Solution().merge(input);

assertThat(actual, equalTo(expected));
assertThat(new Solution().merge(input), equalTo(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

public class SolutionTest {
@Test
public void insertInterval() {
public void insert() {
int[][] expected = {{1, 5}, {6, 9}};
int[][] actual = new Solution().insert(new int[][] {{1, 3}, {6, 9}}, new int[] {2, 5});

assertThat(actual, equalTo(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
public class SolutionTest {
@Test
public void generateMatrix() {
int[][] actual = new Solution().generateMatrix(3);
int[][] expected = {{1, 2, 3}, {8, 9, 4}, {7, 6, 5}};
assertThat(actual, equalTo(expected));
assertThat(new Solution().generateMatrix(3), equalTo(expected));
}
}
3 changes: 1 addition & 2 deletions src/test/java/g0001_0100/s0061_rotate_list/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

public class SolutionTest {
@Test
public void rotateList() {
public void rotateRight() {
ListNode headActual = new ListNode(1);
headActual.next = new ListNode(2);
headActual.next.next = new ListNode(3);
headActual.next.next.next = new ListNode(4);
headActual.next.next.next.next = new ListNode(5);

assertThat(new Solution().rotateRight(headActual, 2).toString(), equalTo("4, 5, 1, 2, 3"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class SolutionTest {
@Test
public void minimumPathSum() {
public void minPathSum() {
int[][] expected = {{1, 3, 1}, {1, 5, 1}, {4, 2, 1}};
assertThat(new Solution().minPathSum(expected), equalTo(7));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/g0001_0100/s0069_sqrtx/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class SolutionTest {
@Test
public void sqrtx() {
public void mySqrt() {
assertThat(new Solution().mySqrt(4), equalTo(2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
public class SolutionTest {
@Test
public void searchMatrix() {
assertThat(
new Solution()
.searchMatrix(
new int[][] {{1, 3, 5, 7}, {10, 11, 16, 20}, {23, 30, 34, 60}}, 3),
equalTo(true));
int[][] input = {{1, 3, 5, 7}, {10, 11, 16, 20}, {23, 30, 34, 60}};
assertThat(new Solution().searchMatrix(input, 3), equalTo(true));
}
}
10 changes: 2 additions & 8 deletions src/test/java/g0001_0100/s0079_submissions/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
public class SolutionTest {
@Test
public void exist() {
assertThat(
new Solution()
.exist(
new char[][] {
{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}
},
"ABCCED"),
equalTo(true));
char[][] input = {{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}};
assertThat(new Solution().exist(input, "ABCCED"), equalTo(true));
}
}