check.odin (581B)
1 package check 2 3 import "core:encoding/json" 4 import "core:testing" 5 6 SAMPLE :: #load("sample.json", string) 7 8 @(test) 9 parses :: proc(t: ^testing.T) { 10 root: Root 11 err := json.unmarshal_string(SAMPLE, &root) 12 testing.expectf(t, err == nil, "unmarshal failed: %v", err) 13 testing.expect_value(t, len(root.points), 2) 14 testing.expect_value(t, root.points[1].x, 3) 15 mat := root.matrix_.? or_else nil 16 testing.expect_value(t, len(mat), 2) 17 testing.expect_value(t, mat[1][0], 3) 18 tags := root.tags.? or_else nil 19 testing.expect_value(t, len(tags), 1) 20 testing.expect_value(t, tags[0], "a") 21 }