@@ -38,7 +38,7 @@ public void testSimplePath() throws Exception
38
38
assertTrue (ptr .matches ());
39
39
assertNull (ptr .tail ());
40
40
assertNull (ptr .head ());
41
- assertEquals ( "" , ptr .getMatchingProperty ());
41
+ assertNull ( ptr .getMatchingProperty ());
42
42
assertEquals (-1 , ptr .getMatchingIndex ());
43
43
}
44
44
@@ -80,21 +80,37 @@ public void testLast()
80
80
assertEquals ("name" , leaf .getMatchingProperty ());
81
81
}
82
82
83
- public void testEmpty ()
83
+ public void testEmptyPointer ()
84
84
{
85
85
assertSame (JsonPointer .EMPTY , JsonPointer .empty ());
86
86
assertSame (JsonPointer .EMPTY , JsonPointer .compile ("" ));
87
+ final JsonPointer empty = JsonPointer .empty ();
88
+ assertEquals ("" , empty .toString ());
89
+
90
+ // As per [core#788], should NOT match Property with "empty String"
91
+ assertFalse (empty .mayMatchProperty ());
92
+ assertFalse (empty .mayMatchElement ());
93
+ assertEquals (-1 , empty .getMatchingIndex ());
94
+ assertNull (empty .getMatchingProperty ());
87
95
}
88
96
89
- public void testEmptyName ()
97
+ public void testPointerWithEmptyPropertyName ()
90
98
{
91
99
// note: this is acceptable, to match property in '{"":3}', for example
92
100
// and NOT same as what empty point, "", is.
93
101
JsonPointer ptr = JsonPointer .compile ("/" );
94
102
assertNotNull (ptr );
95
103
assertNotSame (JsonPointer .EMPTY , ptr );
96
-
104
+
97
105
assertEquals ("/" , ptr .toString ());
106
+ assertTrue (ptr .mayMatchProperty ());
107
+ assertFalse (ptr .mayMatchElement ());
108
+ assertEquals (-1 , ptr .getMatchingIndex ());
109
+ assertEquals ("" , ptr .getMatchingProperty ());
110
+ assertTrue (ptr .matchesProperty ("" ));
111
+ assertFalse (ptr .matchesElement (0 ));
112
+ assertFalse (ptr .matchesElement (-1 ));
113
+ assertFalse (ptr .matchesProperty ("1" ));
98
114
}
99
115
100
116
// mostly for test coverage, really...
0 commit comments