mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
added test for checking if the JSONPointer is immutable
This commit is contained in:
parent
2eed4be5fc
commit
adb3118d31
1 changed files with 12 additions and 0 deletions
|
@ -2,6 +2,7 @@ package org.json.junit;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONPointer;
|
||||
|
@ -143,5 +144,16 @@ public class JSONPointerTest {
|
|||
assertEquals("#/g%7Ch", new JSONPointer("/g|h").toURIFragment());
|
||||
assertEquals("#/m%7En", new JSONPointer("/m~n").toURIFragment());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tokenListIsCopiedInConstructor() {
|
||||
JSONPointer.Builder b = JSONPointer.builder().append("key1");
|
||||
JSONPointer jp1 = b.build();
|
||||
b.append("key2");
|
||||
JSONPointer jp2 = b.build();
|
||||
if(jp1.toString().equals(jp2.toString())) {
|
||||
fail("Oops, my pointers are sharing a backing array");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue