Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ expressed as JSON Schema definitions.
| ISO | [ISO 8601-1:2019](https://www.iso.org/standard/70907.html) | Date and time — Representations for information interchange — Part 1: Basic rules |
| ISO | [ISO 80000-1:2022](https://www.iso.org/standard/76921.html) | Quantities and units — Part 1: General |
| ISO/IEC | [ISO/IEC 2382:2015](https://www.iso.org/standard/63598.html) | Information technology — Vocabulary |
| ISO/IEC | [ISO/IEC 9899:2024](https://www.iso.org/standard/82075.html) | Programming languages — C |
| JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification |
| JSON Schema | [Draft 2020-12](https://json-schema.org/draft/2020-12/json-schema-core) | JSON Schema: A Media Type for Describing JSON Documents |

Expand Down
10 changes: 10 additions & 0 deletions schemas/iso/c/2024/bool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Boolean Type (bool)",
"description": "A boolean type that can hold the values 0 (false) or 1 (true)",
"$comment": "In C, bool is represented as an integer type that can only hold 0 or 1. Defined in `<stdbool.h>` as `_Bool`",
"examples": [ 0, 1 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"enum": [ 0, 1 ]
}
29 changes: 29 additions & 0 deletions schemas/iso/c/2024/double.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Double Precision Floating Point (double)",
"description": "A double precision (64-bit) floating point type conforming to IEC 60559 (IEEE 754)",
"$comment": "The minimum and maximum represent `DBL_MAX` and `-DBL_MAX`. Special floating-point values are defined in a separate schema",
"examples": [
0.0,
1.5,
-3.14159,
299800000.0,
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"NAN",
"INFINITY",
"-INFINITY"
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"anyOf": [
{
"type": "number",
"maximum": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"minimum": -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
},
{
"$ref": "./float-special.json"
}
]
}
9 changes: 9 additions & 0 deletions schemas/iso/c/2024/float-special.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Special Floating-Point Values",
"description": "Special floating-point values as defined in `<math.h>`. These are represented as strings since JSON numbers cannot express these values",
"examples": [ "NAN", "INFINITY", "-INFINITY" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"enum": [ "NAN", "INFINITY", "-INFINITY" ]
}
28 changes: 28 additions & 0 deletions schemas/iso/c/2024/float.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Single Precision Floating Point (float)",
"description": "A single precision (32-bit) floating point type conforming to IEC 60559 (IEEE 754)",
"$comment": "The minimum and maximum represent `FLT_MAX` and `-FLT_MAX`. Special floating-point values are defined in a separate schema",
"examples": [
0.0,
1.5,
-3.14,
340282346600000016151267322115014000640.0,
-340282346600000016151267322115014000640.0,
"NAN",
"INFINITY",
"-INFINITY"
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"anyOf": [
{
"type": "number",
"maximum": 340282346600000016151267322115014000640.0,
"minimum": -340282346600000016151267322115014000640.0
},
{
"$ref": "./float-special.json"
}
]
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/int16_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Signed 16-bit Integer (int16_t)",
"description": "A signed integer type with width of exactly 16 bits",
"examples": [ 0, 1, -1, 32767, -32768, 1000, -1000 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 32767,
"minimum": -32768
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/int32_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Signed 32-bit Integer (int32_t)",
"description": "A signed integer type with width of exactly 32 bits",
"examples": [ 0, 1, -1, 2147483647, -2147483648, 42, -999 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 2147483647,
"minimum": -2147483648
}
19 changes: 19 additions & 0 deletions schemas/iso/c/2024/int64_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Signed 64-bit Integer (int64_t)",
"description": "A signed integer type with width of exactly 64 bits",
"examples": [
0,
1,
-1,
9223372036854775807,
-9223372036854775808,
1000000000,
-1000000000
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 9223372036854775807,
"minimum": -9223372036854775808
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/int8_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Signed 8-bit Integer (int8_t)",
"description": "A signed integer type with width of exactly 8 bits",
"examples": [ 0, 1, -1, 127, -128, 42, -99 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 127,
"minimum": -128
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/uint16_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Unsigned 16-bit Integer (uint16_t)",
"description": "An unsigned integer type with width of exactly 16 bits",
"examples": [ 0, 1, 65535, 32768, 1000 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 65535,
"minimum": 0
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/uint32_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Unsigned 32-bit Integer (uint32_t)",
"description": "An unsigned integer type with width of exactly 32 bits",
"examples": [ 0, 1, 4294967295, 2147483648, 42 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 4294967295,
"minimum": 0
}
11 changes: 11 additions & 0 deletions schemas/iso/c/2024/uint8_t.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Unsigned 8-bit Integer (uint8_t)",
"description": "An unsigned integer type with width of exactly 8 bits",
"examples": [ 0, 1, 255, 128, 42 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"type": "integer",
"maximum": 255,
"minimum": 0
}
61 changes: 61 additions & 0 deletions test/iso/c/2024/bool.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/iso/c/2024/bool.json",
"tests": [
{
"description": "Valid - 0 (false)",
"data": 0,
"valid": true
},
{
"description": "Valid - 1 (true)",
"data": 1,
"valid": true
},
{
"description": "Invalid - 2",
"data": 2,
"valid": false
},
{
"description": "Invalid - negative number",
"data": -1,
"valid": false
},
{
"description": "Invalid - large positive number",
"data": 100,
"valid": false
},
{
"description": "Invalid type - string",
"data": "true",
"valid": false
},
{
"description": "Invalid type - boolean",
"data": true,
"valid": false
},
{
"description": "Invalid type - null",
"data": null,
"valid": false
},
{
"description": "Invalid type - array",
"data": [],
"valid": false
},
{
"description": "Invalid type - object",
"data": {},
"valid": false
},
{
"description": "Invalid type - float",
"data": 0.5,
"valid": false
}
]
}
116 changes: 116 additions & 0 deletions test/iso/c/2024/double.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/iso/c/2024/double.json",
"tests": [
{
"description": "Valid - zero",
"data": 0.0,
"valid": true
},
{
"description": "Valid - positive value",
"data": 1.5,
"valid": true
},
{
"description": "Valid - negative value",
"data": -3.14159,
"valid": true
},
{
"description": "Valid - scientific notation",
"data": 299800000.0,
"valid": true
},
{
"description": "Valid - maximum value",
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"valid": true
},
{
"description": "Valid - minimum value",
"data": -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"valid": true
},
{
"description": "Valid - special value NAN",
"data": "NAN",
"valid": true
},
{
"description": "Valid - special value INFINITY",
"data": "INFINITY",
"valid": true
},
{
"description": "Valid - special value -INFINITY",
"data": "-INFINITY",
"valid": true
},
{
"description": "Invalid - string with wrong case",
"data": "nan",
"valid": false
},
{
"description": "Invalid - string with wrong case",
"data": "infinity",
"valid": false
},
{
"description": "Invalid - JavaScript style",
"data": "Infinity",
"valid": false
},
{
"description": "Invalid - wrong special value string",
"data": "inf",
"valid": false
},
{
"description": "Invalid - numeric string",
"data": "1.5",
"valid": false
},
{
"description": "Invalid type - boolean",
"data": false,
"valid": false
},
{
"description": "Invalid type - null",
"data": null,
"valid": false
},
{
"description": "Invalid type - array",
"data": [],
"valid": false
},
{
"description": "Invalid type - object",
"data": {},
"valid": false
},
{
"description": "Valid - integer value",
"data": 42,
"valid": true
},
{
"description": "Valid - negative integer value",
"data": -100,
"valid": true
},
{
"description": "Valid - large value within range",
"data": 10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104.0,
"valid": true
},
{
"description": "Valid - small negative value within range",
"data": -10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104.0,
"valid": true
}
]
}
Loading