Skip to content

Commit

Permalink
strengthen test and remove unnecessary BufferedReader creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Jul 9, 2024
1 parent ec0d72c commit b8b95e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/nolij/zson/Zson.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public static <T> T parseFile(@NotNull Path path) throws IOException {
@Contract(pure = true)
public static <T> T parseString(@NotNull String serialized) {
try {
return parse(new BufferedReader(new StringReader(serialized)));
return parse(new StringReader(serialized));
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/ZsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ public void testObject() {
"testEnum": "ONE",
}""";

assertEquals(expected, new Zson().stringify(json));
String actual = new Zson().stringify(json);

assertEquals(expected, actual);

json = Zson.parseString(actual);

TestObject obj = Zson.map2Obj(json, TestObject.class);
assertEquals(42, obj.wow);
Expand Down

0 comments on commit b8b95e9

Please sign in to comment.