RFC6901 JSON Pointer implementation in OCaml using jsont
1Token Escaping Tests
2
3Escape tilde:
4 $ ./test_pointer.exe escape "~"
5 ~0
6 $ ./test_pointer.exe escape "~0"
7 ~00
8 $ ./test_pointer.exe escape "~1"
9 ~01
10
11Escape slash:
12 $ ./test_pointer.exe escape "/"
13 ~1
14 $ ./test_pointer.exe escape "a/b"
15 a~1b
16 $ ./test_pointer.exe escape "/foo/bar"
17 ~1foo~1bar
18
19Combined:
20 $ ./test_pointer.exe escape "~/"
21 ~0~1
22 $ ./test_pointer.exe escape "/~"
23 ~1~0
24 $ ./test_pointer.exe escape "a~b/c"
25 a~0b~1c
26
27No escaping needed:
28 $ ./test_pointer.exe escape "foo"
29 foo
30 $ ./test_pointer.exe escape "hello world"
31 hello world
32
33Unescape:
34 $ ./test_pointer.exe unescape "~0"
35 OK: ~
36 $ ./test_pointer.exe unescape "~1"
37 OK: /
38 $ ./test_pointer.exe unescape "~0~1"
39 OK: ~/
40 $ ./test_pointer.exe unescape "~1~0"
41 OK: /~
42 $ ./test_pointer.exe unescape "a~0b~1c"
43 OK: a~b/c
44 $ ./test_pointer.exe unescape "foo"
45 OK: foo
46
47Unescape errors:
48 $ ./test_pointer.exe unescape "~"
49 ERROR: Invalid JSON Pointer: incomplete escape sequence at end
50 $ ./test_pointer.exe unescape "~2"
51 ERROR: Invalid JSON Pointer: invalid escape sequence ~2
52 $ ./test_pointer.exe unescape "foo~"
53 ERROR: Invalid JSON Pointer: incomplete escape sequence at end