Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 1bc2854

Browse files
author
Thibault Falque
committed
change HashMap to Map and remove catch
1 parent bb6b5d3 commit 1bc2854

File tree

2 files changed

+34
-52
lines changed

2 files changed

+34
-52
lines changed

src/test/java/fr/univartois/sonargo/FunctionFinderTest.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
package fr.univartois.sonargo;
55

66
import static org.junit.Assert.assertEquals;
7-
import static org.junit.Assert.fail;
87

98
import java.io.File;
10-
import java.io.IOException;
119
import java.nio.file.Paths;
12-
import java.util.HashMap;
10+
import java.util.Map;
1311
import java.util.Set;
1412

1513
import org.junit.Before;
@@ -32,25 +30,20 @@ public void init() {
3230

3331
@Test
3432
public void testSearchInFile() {
35-
try {
36-
String path = new File(testerContext.fileSystem().baseDir(), "test_test.go").getPath();
37-
38-
FunctionFinder f = new FunctionFinder(testerContext);
39-
f.searchFunctionInFile(Paths.get(path));
40-
HashMap<String, String> result = f.getResult();
41-
Set<String> expected = new java.util.HashSet<String>();
42-
expected.add("TestEasyDef");
43-
expected.add("TestSpaceDef");
44-
expected.add("TestNoSpaceDef");
45-
expected.add("TestTwoLines1");
46-
expected.add("TestTwoLines2");
47-
expected.add("TestNested");
48-
expected.add("TestSuite");
49-
assertEquals(expected, result.keySet());
50-
51-
} catch (IOException e) {
52-
fail("IOException thrown in test.");
53-
}
33+
String path = new File(testerContext.fileSystem().baseDir(), "test_test.go").getPath();
34+
35+
FunctionFinder f = new FunctionFinder(testerContext);
36+
f.searchFunctionInFile(Paths.get(path));
37+
Map<String, String> result = f.getResult();
38+
Set<String> expected = new java.util.HashSet<String>();
39+
expected.add("TestEasyDef");
40+
expected.add("TestSpaceDef");
41+
expected.add("TestNoSpaceDef");
42+
expected.add("TestTwoLines1");
43+
expected.add("TestTwoLines2");
44+
expected.add("TestNested");
45+
expected.add("TestSuite");
46+
assertEquals(expected, result.keySet());
5447

5548
}
5649

src/test/java/fr/univartois/sonargo/gotest/FunctionFinderTest.java

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
import static org.junit.Assert.assertEquals;
77
import static org.junit.Assert.assertTrue;
8-
import static org.junit.Assert.fail;
98

109
import java.io.File;
11-
import java.io.IOException;
1210
import java.nio.file.Paths;
13-
import java.util.HashMap;
11+
import java.util.Map;
1412
import java.util.Set;
1513

1614
import org.junit.Before;
@@ -36,40 +34,31 @@ public void init() {
3634

3735
@Test
3836
public void testSearchInFile() {
39-
try {
40-
String path = new File(TestUtils.getTestBaseDir().baseDir(), "test_test.go").getAbsolutePath();
41-
LOGGER.info("testSearchInFile " + path);
42-
FunctionFinder f = new FunctionFinder(testerContext);
43-
f.searchFunctionInFile(Paths.get(path));
44-
HashMap<String, String> result = f.getResult();
45-
Set<String> expected = new java.util.HashSet<String>();
46-
expected.add("TestEasyDef");
47-
expected.add("TestSpaceDef");
48-
expected.add("TestNoSpaceDef");
49-
expected.add("TestTwoLines1");
50-
expected.add("TestTwoLines2");
51-
expected.add("TestNested");
52-
expected.add("TestSuite");
53-
assertEquals(expected, result.keySet());
37+
String path = new File(TestUtils.getTestBaseDir().baseDir(), "test_test.go").getAbsolutePath();
38+
LOGGER.info("testSearchInFile " + path);
39+
FunctionFinder f = new FunctionFinder(testerContext);
40+
f.searchFunctionInFile(Paths.get(path));
41+
Map<String, String> result = f.getResult();
42+
Set<String> expected = new java.util.HashSet<String>();
43+
expected.add("TestEasyDef");
44+
expected.add("TestSpaceDef");
45+
expected.add("TestNoSpaceDef");
46+
expected.add("TestTwoLines1");
47+
expected.add("TestTwoLines2");
48+
expected.add("TestNested");
49+
expected.add("TestSuite");
50+
assertEquals(expected, result.keySet());
5451

55-
} catch (IOException e) {
56-
fail("IOException thrown in test.");
57-
}
5852
}
5953

6054
@Test
6155
public void testSearchFunction() {
62-
try {
63-
LOGGER.info("testSearchFunction " + testerContext.fileSystem().baseDir());
64-
FunctionFinder f = new FunctionFinder(testerContext);
65-
HashMap<String, String> nameFunction = f.searchFunction();
56+
LOGGER.info("testSearchFunction " + testerContext.fileSystem().baseDir());
57+
FunctionFinder f = new FunctionFinder(testerContext);
58+
Map<String, String> nameFunction = f.searchFunction();
6659

67-
assertTrue(nameFunction.containsKey("TestAverage"));
60+
assertTrue(nameFunction.containsKey("TestAverage"));
6861

69-
} catch (IOException e) {
70-
// TODO Auto-generated catch block
71-
e.printStackTrace();
72-
}
7362
}
7463

7564
}

0 commit comments

Comments
 (0)