Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80d99a9

Browse files
committed
Test push for GitHub Actions
Have solved spotbugs issues andminimized checkstyle errors
1 parent2124c7f commit80d99a9

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

‎src/test/java/com/thealgorithms/datastructures/trees/GenericTreeTest.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
packagecom.thealgorithms.datastructures.trees;
22

3-
43
importorg.junit.jupiter.api.AfterEach;
54
importorg.junit.jupiter.api.BeforeEach;
65
importorg.junit.jupiter.api.Test;
@@ -11,7 +10,9 @@
1110
importjava.io.ByteArrayOutputStream;
1211
importjava.io.PrintStream;
1312

14-
importstaticorg.junit.jupiter.api.Assertions.*;
13+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
14+
importstaticorg.junit.jupiter.api.Assertions.assertFalse;
15+
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
1516

1617
publicclassGenericTreeTest {
1718
GenericTreetree;

‎src/test/java/com/thealgorithms/datastructures/trees/LowestCommonAncestorTest.java‎

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
importjava.io.ByteArrayInputStream;
1313
importjava.io.ByteArrayOutputStream;
1414
importjava.io.PrintStream;
15-
importjava.lang.reflect.InvocationTargetException;
1615
importjava.lang.reflect.Method;
1716
importjava.util.ArrayList;
1817
importjava.util.stream.Stream;
@@ -61,7 +60,7 @@ void setup() {
6160
@ParameterizedTest
6261
@MethodSource("getInput")
6362
@DisplayName("Should return correct common ancestor for any two nodes in the tree")
64-
voidshouldReturnCorrectLCA2(StringsimulatedInput,StringexpectedParent) {
63+
voidshouldReturnCorrectLCAThroughMain(StringsimulatedInput,StringexpectedParent) {
6564
System.setIn(newByteArrayInputStream(simulatedInput.getBytes()));
6665

6766
ByteArrayOutputStreamoutContent =newByteArrayOutputStream();
@@ -88,11 +87,11 @@ public static Stream<Arguments> getInput() {
8887
);
8988
}
9089

90+
@SuppressWarnings("RFI_SET_ACCESSIBLE")
9191
@ParameterizedTest
9292
@CsvSource({"9,4,2","5,6,5","5,4,0","3,8,3","6,3,0","3,3,3"})
9393
@DisplayName("Should return correct common ancestor for any two nodes in the tree")
94-
voidshouldReturnCorrectLCA(intv1,intv2,intexpectedParent) {
95-
try {
94+
voidshouldReturnCorrectLCA(intv1,intv2,intexpectedParent)throwsException {
9695
Methoddfs =LCA.class.getDeclaredMethod("dfs",ArrayList.class,int.class,int.class,int[].class,int[].class);
9796
MethodgetLCA =LCA.class.getDeclaredMethod("getLCA",int.class,int.class,int[].class,int[].class);
9897
dfs.setAccessible(true);
@@ -101,35 +100,26 @@ void shouldReturnCorrectLCA(int v1, int v2, int expectedParent) {
101100
dfs.invoke(null,adj,0, -1,parent,depth);
102101

103102
assertEquals(expectedParent,getLCA.invoke(null,v1,v2,depth,parent));
104-
}catch (NoSuchMethodException |InvocationTargetException |IllegalAccessExceptione) {
105-
thrownewRuntimeException(e);
106-
}
107103
}
108104

105+
@SuppressWarnings("RFI_SET_ACCESSIBLE")
109106
@Test
110-
voidshouldReturnCorrectDepthsForArray() {
111-
try {
112-
Methoddfs =LCA.class.getDeclaredMethod("dfs",ArrayList.class,int.class,int.class,int[].class,int[].class);
113-
dfs.setAccessible(true);
107+
voidshouldReturnCorrectDepthsForArray()throwsException {
108+
Methoddfs =LCA.class.getDeclaredMethod("dfs",ArrayList.class,int.class,int.class,int[].class,int[].class);
109+
dfs.setAccessible(true);
114110

115-
dfs.invoke(null,adj,0, -1,parent,depth);
116-
}catch (NoSuchMethodException |InvocationTargetException |IllegalAccessExceptione) {
117-
thrownewRuntimeException(e);
118-
}
111+
dfs.invoke(null,adj,0, -1,parent,depth);
119112

120113
assertArrayEquals(newint[] {0,1,1,2,2,2,3,3,4,4},depth);
121114
}
122115

116+
@SuppressWarnings("RFI_SET_ACCESSIBLE")
123117
@Test
124-
voidshouldReturnCorrectParentsForArray() {
125-
try {
126-
Methoddfs =LCA.class.getDeclaredMethod("dfs",ArrayList.class,int.class,int.class,int[].class,int[].class);
127-
dfs.setAccessible(true);
118+
voidshouldReturnCorrectParentsForArray()throwsException {
119+
Methoddfs =LCA.class.getDeclaredMethod("dfs",ArrayList.class,int.class,int.class,int[].class,int[].class);
120+
dfs.setAccessible(true);
128121

129-
dfs.invoke(null,adj,0, -1,parent,depth);
130-
}catch (NoSuchMethodException |InvocationTargetException |IllegalAccessExceptione) {
131-
thrownewRuntimeException(e);
132-
}
122+
dfs.invoke(null,adj,0, -1,parent,depth);
133123

134124
assertArrayEquals(newint[] {0,0,0,2,2,1,5,3,7,7},parent);
135125
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp