mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 19:14:15 +08:00
added test for checking if the JSONPointer is immutable
This commit is contained in:
@@ -2,6 +2,7 @@ package org.json.junit;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONPointer;
|
import org.json.JSONPointer;
|
||||||
@@ -144,4 +145,15 @@ public class JSONPointerTest {
|
|||||||
assertEquals("#/m%7En", new JSONPointer("/m~n").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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user