MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / testRemove

Method testRemove

src/test/java/com/amazon/ion/StructTest.java:780–820  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

778
779
780 @Test
781 public void testRemove()
782 {
783 IonStruct s = (IonStruct) oneValue("{a:1,b:2,b:3,c:4}");
784
785 IonValue v = s.remove("c");
786 checkInt(4, v);
787 assertEquals(3, s.size());
788 assertNull(s.get("c"));
789
790 v = s.remove("q");
791 assertNull(v);
792 assertEquals(3, s.size());
793 assertNull(s.get("q"));
794
795 v = s.remove("a");
796 checkInt(1, v);
797
798 v = s.remove("b");
799 assertTrue(v.getType() == IonType.INT);
800 assertEquals(1, s.size());
801 long leftoverB = ((IonInt)s.get("b")).longValue();
802 assertTrue(leftoverB == 2 || leftoverB == 3);
803
804 try {
805 s.remove((String) null);
806 fail("Expected NullPointerException");
807 }
808 catch (NullPointerException e) { }
809
810 testMultithreadedAccess(s);
811
812 s = system().newEmptyStruct();
813 assertNull(s.remove("something"));
814 assertTrue(s.isEmpty());
815 assertFalse(s.isNullValue());
816
817 s = system().newNullStruct();
818 assertNull(s.remove("something"));
819 assertTrue(s.isNullValue());
820 }
821
822 public void testRemoveClearsFieldName(IonStruct s)
823 {

Callers

nothing calls this directly

Calls 15

removeMethod · 0.95
sizeMethod · 0.95
getMethod · 0.95
getTypeMethod · 0.95
failMethod · 0.80
longValueMethod · 0.65
newEmptyStructMethod · 0.65
isEmptyMethod · 0.65
isNullValueMethod · 0.65
newNullStructMethod · 0.65
oneValueMethod · 0.45

Tested by

no test coverage detected