Skip to content

Commit cabbd65

Browse files
authored
Merge pull request #735 from zaplapl/main
Add tests to ensure Unicode string comparison is by codepoint - Issue #570
2 parents ef78a0e + ed74ee7 commit cabbd65

File tree

6 files changed

+258
-0
lines changed

6 files changed

+258
-0
lines changed

tests/draft2019-09/const.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,49 @@
383383
"valid": false
384384
}
385385
]
386+
},
387+
{
388+
"description": "characters with the same visual representation but different codepoint",
389+
"schema": {
390+
"$schema": "https://json-schema.org/draft/2019-09/schema",
391+
"const": "μ",
392+
"$comment": "U+03BC"
393+
},
394+
"tests": [
395+
{
396+
"description": "character uses the same codepoint",
397+
"data": "μ",
398+
"comment": "U+03BC",
399+
"valid": true
400+
},
401+
{
402+
"description": "character looks the same but uses a different codepoint",
403+
"data": "µ",
404+
"comment": "U+00B5",
405+
"valid": false
406+
}
407+
]
408+
},
409+
{
410+
"description": "characters with the same visual representation, but different number of codepoints",
411+
"schema": {
412+
"$schema": "https://json-schema.org/draft/2019-09/schema",
413+
"const": "ä",
414+
"$comment": "U+00E4"
415+
},
416+
"tests": [
417+
{
418+
"description": "character uses the same codepoint",
419+
"data": "ä",
420+
"comment": "U+00E4",
421+
"valid": true
422+
},
423+
{
424+
"description": "character looks the same but uses combining marks",
425+
"data": "",
426+
"comment": "a, U+0308",
427+
"valid": false
428+
}
429+
]
386430
}
387431
]

tests/draft2020-12/const.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,49 @@
383383
"valid": false
384384
}
385385
]
386+
},
387+
{
388+
"description": "characters with the same visual representation but different codepoint",
389+
"schema": {
390+
"$schema": "https://json-schema.org/draft/2020-12/schema",
391+
"const": "μ",
392+
"$comment": "U+03BC"
393+
},
394+
"tests": [
395+
{
396+
"description": "character uses the same codepoint",
397+
"data": "μ",
398+
"comment": "U+03BC",
399+
"valid": true
400+
},
401+
{
402+
"description": "character looks the same but uses a different codepoint",
403+
"data": "µ",
404+
"comment": "U+00B5",
405+
"valid": false
406+
}
407+
]
408+
},
409+
{
410+
"description": "characters with the same visual representation, but different number of codepoints",
411+
"schema": {
412+
"$schema": "https://json-schema.org/draft/2020-12/schema",
413+
"const": "ä",
414+
"$comment": "U+00E4"
415+
},
416+
"tests": [
417+
{
418+
"description": "character uses the same codepoint",
419+
"data": "ä",
420+
"comment": "U+00E4",
421+
"valid": true
422+
},
423+
{
424+
"description": "character looks the same but uses combining marks",
425+
"data": "",
426+
"comment": "a, U+0308",
427+
"valid": false
428+
}
429+
]
386430
}
387431
]

tests/draft4/enum.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,47 @@
316316
"valid": false
317317
}
318318
]
319+
},
320+
{
321+
"description": "characters with the same visual representation but different codepoint",
322+
"schema": {
323+
"enum": ["μ"],
324+
"$comment": "U+03BC"
325+
},
326+
"tests": [
327+
{
328+
"description": "character uses the same codepoint",
329+
"data": "μ",
330+
"comment": "U+03BC",
331+
"valid": true
332+
},
333+
{
334+
"description": "character looks the same but uses a different codepoint",
335+
"data": "µ",
336+
"comment": "U+00B5",
337+
"valid": false
338+
}
339+
]
340+
},
341+
{
342+
"description": "characters with the same visual representation, but different number of codepoints",
343+
"schema": {
344+
"enum": ["ä"],
345+
"$comment": "U+00E4"
346+
},
347+
"tests": [
348+
{
349+
"description": "character uses the same codepoint",
350+
"data": "ä",
351+
"comment": "U+00E4",
352+
"valid": true
353+
},
354+
{
355+
"description": "character looks the same but uses combining marks",
356+
"data": "",
357+
"comment": "a, U+0308",
358+
"valid": false
359+
}
360+
]
319361
}
320362
]

tests/draft6/const.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,47 @@
338338
"valid": false
339339
}
340340
]
341+
},
342+
{
343+
"description": "characters with the same visual representation but different codepoint",
344+
"schema": {
345+
"const": "μ",
346+
"$comment": "U+03BC"
347+
},
348+
"tests": [
349+
{
350+
"description": "character uses the same codepoint",
351+
"data": "μ",
352+
"comment": "U+03BC",
353+
"valid": true
354+
},
355+
{
356+
"description": "character looks the same but uses a different codepoint",
357+
"data": "µ",
358+
"comment": "U+00B5",
359+
"valid": false
360+
}
361+
]
362+
},
363+
{
364+
"description": "characters with the same visual representation, but different number of codepoints",
365+
"schema": {
366+
"const": "ä",
367+
"$comment": "U+00E4"
368+
},
369+
"tests": [
370+
{
371+
"description": "character uses the same codepoint",
372+
"data": "ä",
373+
"comment": "U+00E4",
374+
"valid": true
375+
},
376+
{
377+
"description": "character looks the same but uses combining marks",
378+
"data": "",
379+
"comment": "a, U+0308",
380+
"valid": false
381+
}
382+
]
341383
}
342384
]

tests/draft7/const.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,47 @@
338338
"valid": false
339339
}
340340
]
341+
},
342+
{
343+
"description": "characters with the same visual representation but different codepoint",
344+
"schema": {
345+
"const": "μ",
346+
"$comment": "U+03BC"
347+
},
348+
"tests": [
349+
{
350+
"description": "character uses the same codepoint",
351+
"data": "μ",
352+
"comment": "U+03BC",
353+
"valid": true
354+
},
355+
{
356+
"description": "character looks the same but uses a different codepoint",
357+
"data": "µ",
358+
"comment": "U+00B5",
359+
"valid": false
360+
}
361+
]
362+
},
363+
{
364+
"description": "characters with the same visual representation, but different number of codepoints",
365+
"schema": {
366+
"const": "ä",
367+
"$comment": "U+00E4"
368+
},
369+
"tests": [
370+
{
371+
"description": "character uses the same codepoint",
372+
"data": "ä",
373+
"comment": "U+00E4",
374+
"valid": true
375+
},
376+
{
377+
"description": "character looks the same but uses combining marks",
378+
"data": "",
379+
"comment": "a, U+0308",
380+
"valid": false
381+
}
382+
]
341383
}
342384
]

tests/v1/const.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,5 +383,49 @@
383383
"valid": false
384384
}
385385
]
386+
},
387+
{
388+
"description": "characters with the same visual representation but different codepoint",
389+
"schema": {
390+
"$schema": "https://json-schema.org/v1",
391+
"const": "μ",
392+
"$comment": "U+03BC"
393+
},
394+
"tests": [
395+
{
396+
"description": "character uses the same codepoint",
397+
"data": "μ",
398+
"comment": "U+03BC",
399+
"valid": true
400+
},
401+
{
402+
"description": "character looks the same but uses a different codepoint",
403+
"data": "µ",
404+
"comment": "U+00B5",
405+
"valid": false
406+
}
407+
]
408+
},
409+
{
410+
"description": "characters with the same visual representation, but different number of codepoints",
411+
"schema": {
412+
"$schema": "https://json-schema.org/v1",
413+
"const": "ä",
414+
"$comment": "U+00E4"
415+
},
416+
"tests": [
417+
{
418+
"description": "character uses the same codepoint",
419+
"data": "ä",
420+
"comment": "U+00E4",
421+
"valid": true
422+
},
423+
{
424+
"description": "character looks the same but uses combining marks",
425+
"data": "",
426+
"comment": "a, U+0308",
427+
"valid": false
428+
}
429+
]
386430
}
387431
]

0 commit comments

Comments
 (0)