Skip to content

Commit 1ed957b

Browse files
committed
Added tests for round-tripping pointers from paths to parts
1 parent 95a5b46 commit 1ed957b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,28 @@ def test_eol(self):
4747
self.assertTrue(isinstance(resolve_pointer(doc, "/foo/-"), EndOfList))
4848
self.assertRaises(JsonPointerException, resolve_pointer, doc, "/foo/-/1")
4949

50+
def test_round_trip(self):
51+
paths = [
52+
"",
53+
"/foo",
54+
"/foo/0",
55+
"/",
56+
"/a~1b",
57+
"/c%d",
58+
"/e^f",
59+
"/g|h",
60+
"/i\\j",
61+
"/k\"l",
62+
"/ ",
63+
"/m~0n",
64+
]
65+
for path in paths:
66+
ptr = JsonPointer(path)
67+
self.assertEqual(path, ptr.path)
68+
69+
parts = ptr.parts
70+
new_ptr = JsonPointer.from_parts(parts)
71+
self.assertEqual(ptr, new_ptr)
5072

5173
class ComparisonTests(unittest.TestCase):
5274

0 commit comments

Comments
 (0)