1
0
Fork 0
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:
Bence Erős 2016-05-05 16:00:15 +02:00
parent 2eed4be5fc
commit adb3118d31

View file

@ -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;
@ -143,5 +144,16 @@ public class JSONPointerTest {
assertEquals("#/g%7Ch", new JSONPointer("/g|h").toURIFragment()); assertEquals("#/g%7Ch", new JSONPointer("/g|h").toURIFragment());
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");
}
}
} }