odin-jsonschema

Implementation of JSON schema for Odin
Log | Files | Refs | LICENSE

check.odin (583B)


      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, root.count, 7)
     14 	testing.expect_value(t, root.ratio, 0.5)
     15 	testing.expect_value(t, root.active, true)
     16 	testing.expect_value(t, root.label, "x")
     17 	arr, is_array := root.anything.(json.Array)
     18 	testing.expect(t, is_array, "anything should hold a json.Array")
     19 	testing.expect_value(t, len(arr), 3)
     20 }