Skip to content

Commit bd8ab26

Browse files
committed
test(draft2020-12): add literal Unicode coverage for pattern and patternProperties
1 parent 4253477 commit bd8ab26

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

tests/draft2020-12/pattern.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,49 @@
6161
"valid": true
6262
}
6363
]
64+
},
65+
{
66+
"description": "pattern with literal Unicode characters (draft 2020-12)",
67+
"schema": {
68+
"$schema": "https://json-schema.org/draft/2020-12/schema",
69+
"pattern": "^λ+$"
70+
},
71+
"tests": [
72+
{
73+
"description": "matching repeated Greek letter",
74+
"data": "λλλ",
75+
"valid": true
76+
},
77+
{
78+
"description": "non-matching mixed characters",
79+
"data": "λaλ",
80+
"valid": false
81+
},
82+
{
83+
"description": "matching single literal",
84+
"data": "λ",
85+
"valid": true
86+
}
87+
]
88+
},
89+
{
90+
"description": "pattern with literal emoji character",
91+
"schema": {
92+
"$schema": "https://json-schema.org/draft/2020-12/schema",
93+
"pattern": "^😊$"
94+
},
95+
"tests": [
96+
{
97+
"description": "exact emoji match",
98+
"data": "😊",
99+
"valid": true
100+
},
101+
{
102+
"description": "emoji plus extra character fails",
103+
"data": "😊a",
104+
"valid": false
105+
}
106+
]
64107
}
108+
65109
]

tests/draft2020-12/patternProperties.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,32 @@
172172
"valid": true
173173
}
174174
]
175+
},
176+
{
177+
"description": "patternProperties with literal Unicode key patterns (draft 2020-12)",
178+
"schema": {
179+
"$schema": "https://json-schema.org/draft/2020-12/schema",
180+
"patternProperties": {
181+
"^λ+$": { "type": "number" }
182+
}
183+
},
184+
"tests": [
185+
{
186+
"description": "matching Unicode property name",
187+
"data": { "λλ": 1 },
188+
"valid": true
189+
},
190+
{
191+
"description": "non-matching property name ignored",
192+
"data": { "aa": 1 },
193+
"valid": true
194+
},
195+
{
196+
"description": "matching property name with invalid type",
197+
"data": { "λλ": "not number" },
198+
"valid": false
199+
}
200+
]
175201
}
202+
176203
]

0 commit comments

Comments
 (0)