Skip to content

Commit

Permalink
Regex for removing unnecessary newlines, adjust tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Neo <[email protected]>
  • Loading branch information
Uacias authored and neotheprogramist committed Nov 21, 2023
1 parent a6564c9 commit de98029
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void commit(final NodeUpdater nodeUpdater) {
* @return The DOT representation of the Verkle Trie.
*/
public String toDotTree(Boolean showRepeatingEdges) {
return String.format("digraph VerkleTrie {\n%s}\n", getRoot().toDot(showRepeatingEdges));
return String.format("digraph VerkleTrie {\n%s\n}", getRoot().toDot(showRepeatingEdges).replaceAll("^\\n+|\\n+$", ""));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void exportToDotFile(String verkleTrieDotString, String filePath)

try (BufferedWriter writer =
new BufferedWriter(new FileWriter(path.toString(), StandardCharsets.UTF_8))) {
writer.write(verkleTrieDotString + "\n");
writer.write(verkleTrieDotString);
}

} catch (AccessDeniedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void testToDotTrieOneValueNoRepeatingEdgesExport() throws IOException {
final String fileName = "expectedTreeOneValueNoRepeatingEdges.txt";
final String expectedTree = getResources(fileName);
final String actualTree = trie.toDotTree();
System.out.println(actualTree);

assertEquals(expectedTree, actualTree);
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/VerkleTrie.gv
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,4 @@ NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
}

}
3 changes: 1 addition & 2 deletions src/test/resources/expectedTreeOneValueNoRepeatingEdges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,4 @@ NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
}

}
3 changes: 1 addition & 2 deletions src/test/resources/expectedTreeOneValueRepeatingEdges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1024,5 +1024,4 @@ InternalNode0x -> NullNode0x
NullNode0x[location="0x"]
InternalNode0x -> NullNode0x
NullNode0x[location="0x"]
}

}
3 changes: 1 addition & 2 deletions src/test/resources/expectedTreeTwoValuesNoRepeatingEdges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -517,5 +517,4 @@ NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
NullNode0x[location="0x"]
}

}
3 changes: 1 addition & 2 deletions src/test/resources/expectedTreeTwoValuesRepeatingEdges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1024,5 +1024,4 @@ InternalNode0x -> NullNode0x
NullNode0x[location="0x"]
InternalNode0x -> NullNode0x
NullNode0x[location="0x"]
}

}

0 comments on commit de98029

Please sign in to comment.