@@ -10,3 +10,37 @@ def test_pointer_get():
1010def test_pointer_str ():
1111 assert str (Pointer ([1 ])) == "/1"
1212 assert str (Pointer (["foo" , "bar" , "-" ])) == "/foo/bar/-"
13+
14+
15+ def test_pointer_repr ():
16+ assert repr (Pointer ([1 ])) == "Pointer([1])"
17+ assert repr (Pointer (["foo" , "bar" , "-" ])) == "Pointer(['foo', 'bar', '-'])"
18+
19+
20+ def test_pointer_from_str ():
21+ assert Pointer .from_str ("/1" ) == Pointer (["1" ])
22+ assert Pointer .from_str ("/foo/bar/-" ) == Pointer (["foo" , "bar" , "-" ])
23+
24+
25+ def test_pointer_hash ():
26+ assert hash (Pointer ([1 ])) == hash ((1 ,))
27+ assert hash (Pointer (["foo" , "bar" , "-" ])) == hash (("foo" , "bar" , "-" ))
28+
29+
30+ def test_pointer_set ():
31+ # hash supports comparison operators for use as keys and set elements
32+ # so we exercise that as well
33+ unique_pointers = [Pointer ([1 ]), Pointer (["2" , "3" ])]
34+ duplicated_pointers = unique_pointers + unique_pointers
35+ assert len (set (duplicated_pointers )) == len (unique_pointers )
36+
37+
38+ def test_pointer_eq ():
39+ assert Pointer ([1 ]) != [1 ]
40+ assert Pointer ([1 ]) != Pointer (["1" ])
41+ assert Pointer ([1 ]) != Pointer ([0 ])
42+ assert Pointer ([1 ]) == Pointer ([1 ])
43+
44+
45+ def test_pointer_append ():
46+ assert Pointer ([1 ]).append ("foo" ) == Pointer ([1 , "foo" ])
0 commit comments