Skip to content

Commit

Permalink
Merge pull request #712 from otto-ifak/main
Browse files Browse the repository at this point in the history
Add tests for enum validation with arrays of boolean values
  • Loading branch information
Julian committed Jan 16, 2024
2 parents 589a085 + 9dad3eb commit 544f7c3
Show file tree
Hide file tree
Showing 6 changed files with 540 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/draft-next/enum.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@
}
]
},
{
"description": "enum with [false] does not match [0]",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"enum": [[false]]
},
"tests": [
{
"description": "[false] is valid",
"data": [false],
"valid": true
},
{
"description": "[0] is invalid",
"data": [0],
"valid": false
},
{
"description": "[0.0] is invalid",
"data": [0.0],
"valid": false
}
]
},
{
"description": "enum with true does not match 1",
"schema": {
Expand All @@ -192,6 +216,30 @@
}
]
},
{
"description": "enum with [true] does not match [1]",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"enum": [[true]]
},
"tests": [
{
"description": "[true] is valid",
"data": [true],
"valid": true
},
{
"description": "[1] is invalid",
"data": [1],
"valid": false
},
{
"description": "[1.0] is invalid",
"data": [1.0],
"valid": false
}
]
},
{
"description": "enum with 0 does not match false",
"schema": {
Expand All @@ -216,6 +264,30 @@
}
]
},
{
"description": "enum with [0] does not match [false]",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"enum": [[0]]
},
"tests": [
{
"description": "[false] is invalid",
"data": [false],
"valid": false
},
{
"description": "[0] is valid",
"data": [0],
"valid": true
},
{
"description": "[0.0] is valid",
"data": [0.0],
"valid": true
}
]
},
{
"description": "enum with 1 does not match true",
"schema": {
Expand All @@ -240,6 +312,30 @@
}
]
},
{
"description": "enum with [1] does not match [true]",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"enum": [[1]]
},
"tests": [
{
"description": "[true] is invalid",
"data": [true],
"valid": false
},
{
"description": "[1] is valid",
"data": [1],
"valid": true
},
{
"description": "[1.0] is valid",
"data": [1.0],
"valid": true
}
]
},
{
"description": "nul characters in strings",
"schema": {
Expand Down
96 changes: 96 additions & 0 deletions tests/draft2019-09/enum.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@
}
]
},
{
"description": "enum with [false] does not match [0]",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"enum": [[false]]
},
"tests": [
{
"description": "[false] is valid",
"data": [false],
"valid": true
},
{
"description": "[0] is invalid",
"data": [0],
"valid": false
},
{
"description": "[0.0] is invalid",
"data": [0.0],
"valid": false
}
]
},
{
"description": "enum with true does not match 1",
"schema": {
Expand All @@ -192,6 +216,30 @@
}
]
},
{
"description": "enum with [true] does not match [1]",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"enum": [[true]]
},
"tests": [
{
"description": "[true] is valid",
"data": [true],
"valid": true
},
{
"description": "[1] is invalid",
"data": [1],
"valid": false
},
{
"description": "[1.0] is invalid",
"data": [1.0],
"valid": false
}
]
},
{
"description": "enum with 0 does not match false",
"schema": {
Expand All @@ -216,6 +264,30 @@
}
]
},
{
"description": "enum with [0] does not match [false]",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"enum": [[0]]
},
"tests": [
{
"description": "[false] is invalid",
"data": [false],
"valid": false
},
{
"description": "[0] is valid",
"data": [0],
"valid": true
},
{
"description": "[0.0] is valid",
"data": [0.0],
"valid": true
}
]
},
{
"description": "enum with 1 does not match true",
"schema": {
Expand All @@ -240,6 +312,30 @@
}
]
},
{
"description": "enum with [1] does not match [true]",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"enum": [[1]]
},
"tests": [
{
"description": "[true] is invalid",
"data": [true],
"valid": false
},
{
"description": "[1] is valid",
"data": [1],
"valid": true
},
{
"description": "[1.0] is valid",
"data": [1.0],
"valid": true
}
]
},
{
"description": "nul characters in strings",
"schema": {
Expand Down
96 changes: 96 additions & 0 deletions tests/draft2020-12/enum.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,30 @@
}
]
},
{
"description": "enum with [false] does not match [0]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [[false]]
},
"tests": [
{
"description": "[false] is valid",
"data": [false],
"valid": true
},
{
"description": "[0] is invalid",
"data": [0],
"valid": false
},
{
"description": "[0.0] is invalid",
"data": [0.0],
"valid": false
}
]
},
{
"description": "enum with true does not match 1",
"schema": {
Expand All @@ -192,6 +216,30 @@
}
]
},
{
"description": "enum with [true] does not match [1]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [[true]]
},
"tests": [
{
"description": "[true] is valid",
"data": [true],
"valid": true
},
{
"description": "[1] is invalid",
"data": [1],
"valid": false
},
{
"description": "[1.0] is invalid",
"data": [1.0],
"valid": false
}
]
},
{
"description": "enum with 0 does not match false",
"schema": {
Expand All @@ -216,6 +264,30 @@
}
]
},
{
"description": "enum with [0] does not match [false]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [[0]]
},
"tests": [
{
"description": "[false] is invalid",
"data": [false],
"valid": false
},
{
"description": "[0] is valid",
"data": [0],
"valid": true
},
{
"description": "[0.0] is valid",
"data": [0.0],
"valid": true
}
]
},
{
"description": "enum with 1 does not match true",
"schema": {
Expand All @@ -240,6 +312,30 @@
}
]
},
{
"description": "enum with [1] does not match [true]",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"enum": [[1]]
},
"tests": [
{
"description": "[true] is invalid",
"data": [true],
"valid": false
},
{
"description": "[1] is valid",
"data": [1],
"valid": true
},
{
"description": "[1.0] is valid",
"data": [1.0],
"valid": true
}
]
},
{
"description": "nul characters in strings",
"schema": {
Expand Down
Loading

0 comments on commit 544f7c3

Please sign in to comment.