Skip to content

Commit 6f570f7

Browse files
committed
Define a schema for 64-bit unsigned integers
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 1bfc289 commit 6f570f7

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

schemas/iso/c/2024/uint64.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Unsigned 64-bit Integer (uint64_t)",
4+
"description": "An unsigned integer type with width of exactly 64 bits",
5+
"$comment": "This schema requires a JSON Schema evaluator that supports big integers beyond the 64-bit signed integer interoperability guidelines defined in RFC 8259 for the JSON grammar",
6+
"examples": [ 0, 1, 18446744073709551615, 9223372036854775808, 42 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
9+
"type": "integer",
10+
"maximum": 18446744073709551615,
11+
"minimum": 0
12+
}

test/iso/c/2024/uint64.test.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../../schemas/iso/c/2024/uint64.json",
4+
"tests": [
5+
{
6+
"description": "Valid - zero",
7+
"data": 0,
8+
"valid": true
9+
},
10+
{
11+
"description": "Valid - minimum value",
12+
"data": 0,
13+
"valid": true
14+
},
15+
{
16+
"description": "Valid - maximum value",
17+
"data": 18446744073709551615,
18+
"valid": true
19+
},
20+
{
21+
"description": "Valid - mid-range value",
22+
"data": 9223372036854775808,
23+
"valid": true
24+
},
25+
{
26+
"description": "Valid - positive value",
27+
"data": 42,
28+
"valid": true
29+
},
30+
{
31+
"description": "Valid - large value",
32+
"data": 10000000000000000000,
33+
"valid": true
34+
},
35+
{
36+
"description": "Invalid - negative value",
37+
"data": -1,
38+
"valid": false
39+
},
40+
{
41+
"description": "Invalid - above maximum",
42+
"data": 18446744073709551616,
43+
"valid": false
44+
},
45+
{
46+
"description": "Invalid - large above maximum",
47+
"data": 20000000000000000000,
48+
"valid": false
49+
},
50+
{
51+
"description": "Invalid - large negative value",
52+
"data": -1000,
53+
"valid": false
54+
},
55+
{
56+
"description": "Invalid type - string",
57+
"data": "42",
58+
"valid": false
59+
},
60+
{
61+
"description": "Invalid type - boolean",
62+
"data": true,
63+
"valid": false
64+
},
65+
{
66+
"description": "Invalid type - null",
67+
"data": null,
68+
"valid": false
69+
},
70+
{
71+
"description": "Invalid type - array",
72+
"data": [],
73+
"valid": false
74+
},
75+
{
76+
"description": "Invalid type - object",
77+
"data": {},
78+
"valid": false
79+
},
80+
{
81+
"description": "Invalid type - float",
82+
"data": 42.5,
83+
"valid": false
84+
}
85+
]
86+
}

0 commit comments

Comments
 (0)