| ... | ... | @@ -1995,17 +1995,17 @@ test "parse into struct with duplicate field" { |
| 1995 | 1995 | const ballast = try testing.allocator.alloc(u64, 1); |
| 1996 | 1996 | defer testing.allocator.free(ballast); |
| 1997 | 1997 | |
| 1998 | | const options = ParseOptions{ |
| 1998 | const options = ParseOptions{ |
| 1999 | 1999 | .allocator = testing.allocator, |
| 2000 | 2000 | .duplicate_field_behavior = .UseLast, |
| 2001 | 2001 | }; |
| 2002 | 2002 | const str = "{ \"a\": 1, \"a\": 0.25 }"; |
| 2003 | | |
| 2003 | |
| 2004 | 2004 | const T1 = struct { a: *u64 }; |
| 2005 | | testing.expectError(error.UnexpectedToken, parse(T1, &TokenStream.init(str), options)); |
| 2005 | try testing.expectError(error.UnexpectedToken, parse(T1, &TokenStream.init(str), options)); |
| 2006 | 2006 | |
| 2007 | 2007 | const T2 = struct { a: f64 }; |
| 2008 | | testing.expectEqual(T2{ .a = 0.25 }, try parse(T2, &TokenStream.init(str), options)); |
| 2008 | try testing.expectEqual(T2{ .a = 0.25 }, try parse(T2, &TokenStream.init(str), options)); |
| 2009 | 2009 | } |
| 2010 | 2010 | |
| 2011 | 2011 | /// A non-stream JSON parser which constructs a tree of Value's. |