1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[dsf-gdb] tests: Check if a line tag is defined more than once

As a safety net, fail if a line tag is defined more than once.

Also, allow calling resolveLineTagLocations more than once for a single
test.

Change-Id: I0832d3d28c4d688c38fd33dfc668b0ec6b8c4ffa
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
This commit is contained in:
Simon Marchi 2015-02-18 13:30:02 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 08d96189f1
commit 13978c1567

View file

@ -113,7 +113,7 @@ public class BaseTestCase {
private static boolean fgStatusHandlersEnabled = true;
private static HashMap<String, Integer> fTagLocations = new HashMap<>();
private HashMap<String, Integer> fTagLocations = new HashMap<>();
public GdbLaunch getGDBLaunch() { return fLaunch; }
@ -253,15 +253,19 @@ public class BaseTestCase {
Set<String> tagsToFind = new HashSet<>(Arrays.asList(tags));
String line;
int lineNumber = 1;
fTagLocations.clear();
int numberFound = 0;
line = reader.readLine();
while (line != null) {
for (String tag : tagsToFind) {
if (line.contains(tag)) {
if (fTagLocations.containsKey(tag)) {
throw new RuntimeException("Tag " + tag
+ " was found twice in " + sourceName);
}
fTagLocations.put(tag, lineNumber);
tagsToFind.remove(tag);
numberFound++;
break;
}
}
@ -271,7 +275,7 @@ public class BaseTestCase {
}
/* Make sure all tags have been found */
if (tagsToFind.size() > 0) {
if (numberFound != tagsToFind.size()) {
throw new RuntimeException(
"Some tags were not found in " + sourceName);
}