xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft2020-12/multipleOf.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description": "by int",
4        "schema": {
5            "$schema": "https://json-schema.org/draft/2020-12/schema",
6            "multipleOf": 2
7        },
8        "tests": [
9            {
10                "description": "int by int",
11                "data": 10,
12                "valid": true
13            },
14            {
15                "description": "int by int fail",
16                "data": 7,
17                "valid": false
18            },
19            {
20                "description": "ignores non-numbers",
21                "data": "foo",
22                "valid": true
23            }
24        ]
25    },
26    {
27        "description": "by number",
28        "schema": {
29            "$schema": "https://json-schema.org/draft/2020-12/schema",
30            "multipleOf": 1.5
31        },
32        "tests": [
33            {
34                "description": "zero is multiple of anything",
35                "data": 0,
36                "valid": true
37            },
38            {
39                "description": "4.5 is multiple of 1.5",
40                "data": 4.5,
41                "valid": true
42            },
43            {
44                "description": "35 is not multiple of 1.5",
45                "data": 35,
46                "valid": false
47            }
48        ]
49    },
50    {
51        "description": "by small number",
52        "schema": {
53            "$schema": "https://json-schema.org/draft/2020-12/schema",
54            "multipleOf": 0.0001
55        },
56        "tests": [
57            {
58                "description": "0.0075 is multiple of 0.0001",
59                "data": 0.0075,
60                "valid": true
61            },
62            {
63                "description": "0.00751 is not multiple of 0.0001",
64                "data": 0.00751,
65                "valid": false
66            }
67        ]
68    },
69    {
70        "description": "float division = inf",
71        "schema": {
72            "$schema": "https://json-schema.org/draft/2020-12/schema",
73            "type": "integer", "multipleOf": 0.123456789
74        },
75        "tests": [
76            {
77                "description": "always invalid, but naive implementations may raise an overflow error",
78                "data": 1e308,
79                "valid": false
80            }
81        ]
82    },
83    {
84        "description": "small multiple of large integer",
85        "schema": {
86            "$schema": "https://json-schema.org/draft/2020-12/schema",
87            "type": "integer", "multipleOf": 1e-8
88        },
89        "tests": [
90            {
91                "description": "any integer is a multiple of 1e-8",
92                "data": 12391239123,
93                "valid": true
94            }
95        ]
96    }
97]
98