File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,10 +92,29 @@ def test_oob(self):
9292 self .assertRaises (JsonPointerException , resolve_pointer , doc , '/10' )
9393
9494
95+ class ToLastTests (unittest .TestCase ):
96+
97+ def test_empty_path (self ):
98+ doc = {'a' : [1 , 2 , 3 ]}
99+ ptr = JsonPointer ('' )
100+ last , nxt = ptr .to_last (doc )
101+ self .assertEqual (doc , last )
102+ self .assertTrue (nxt is None )
103+
104+
105+ def test_path (self ):
106+ doc = {'a' : [{'b' : 1 , 'c' : 2 }, 5 ]}
107+ ptr = JsonPointer ('/a/0/b' )
108+ last , nxt = ptr .to_last (doc )
109+ self .assertEqual (last , {'b' : 1 , 'c' : 2 })
110+ self .assertEqual (nxt , 'b' )
111+
112+
95113suite = unittest .TestSuite ()
96114suite .addTest (unittest .makeSuite (SpecificationTests ))
97115suite .addTest (unittest .makeSuite (ComparisonTests ))
98116suite .addTest (unittest .makeSuite (WrongInputTests ))
117+ suite .addTest (unittest .makeSuite (ToLastTests ))
99118
100119modules = ['jsonpointer' ]
101120
You can’t perform that action at this time.
0 commit comments