Skip to content

Commit

Permalink
Add unit test for missing fields in maps
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed May 31, 2024
1 parent 01b9b6c commit a5dd296
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/java/ZsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ public void testObject() {
assertEquals(3.14, obj.pi);
}

@Test
public void testNonexistentFieldInMap() {
Map<String, ZsonValue> json = Map.of("such", new ZsonValue("working"));
TestObject obj = Zson.map2Obj(json, TestObject.class);
assertEquals("working", obj.such);
assertEquals(42, obj.wow);
}

public static class TestObject {
@Comment("look a comment")
public int wow = 42;
Expand Down

0 comments on commit a5dd296

Please sign in to comment.