private void doTestSet(E newValue) { int index = aValidIndex(); E initialValue = getList().get(index); assertEquals( "set(i, x) should return the old element at position i.", initialValue, getList().set(index, newValue)); assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index)); assertEquals("set() should not change the size of a list.", getNumElements(), getList().size()); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(absent = SUPPORTS_SET) public void testSet_unsupported() { try { getList().set(aValidIndex(), e3()); fail("set() should throw UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(SUPPORTS_SET) @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES) public void testSet_nullUnsupported() { try { getList().set(aValidIndex(), null); fail("set(null) should throw NullPointerException"); } catch (NullPointerException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @CollectionFeature.Require(ALLOWS_NULL_VALUES) @ListFeature.Require(SUPPORTS_SET) public void testSet_replacingNull() { E[] elements = createSamplesArray(); int i = aValidIndex(); elements[i] = null; collection = getSubjectGenerator().create(elements); doTestSet(e3()); }
private void doTestSet(E newValue) { int index = aValidIndex(); E initialValue = getList().get(index); assertEquals( "set(i, x) should return the old element at position i.", initialValue, getList().set(index, newValue)); assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index)); assertEquals("set() should not change the size of a list.", getNumElements(), getList().size()); }
private void doTestSet(E newValue) { int index = aValidIndex(); E initialValue = getList().get(index); assertEquals("set(i, x) should return the old element at position i.", initialValue, getList().set(index, newValue)); assertEquals("After set(i, x), get(i) should return x", newValue, getList().get(index)); assertEquals("set() should not change the size of a list.", getNumElements(), getList().size()); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(absent = SUPPORTS_SET) public void testSet_unsupported() { try { getList().set(aValidIndex(), samples.e3); fail("set() should throw UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(absent = SUPPORTS_SET) public void testSet_unsupported() { try { getList().set(aValidIndex(), e3()); fail("set() should throw UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(SUPPORTS_SET) @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES) public void testSet_nullUnsupported() { try { getList().set(aValidIndex(), null); fail("set(null) should throw NullPointerException"); } catch (NullPointerException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @ListFeature.Require(SUPPORTS_SET) @CollectionFeature.Require(absent = ALLOWS_NULL_VALUES) public void testSet_nullUnsupported() { try { getList().set(aValidIndex(), null); fail("set(null) should throw NullPointerException"); } catch (NullPointerException expected) { } expectUnchanged(); }
@CollectionSize.Require(absent = ZERO) @CollectionFeature.Require(ALLOWS_NULL_VALUES) @ListFeature.Require(SUPPORTS_SET) public void testSet_replacingNull() { E[] elements = createSamplesArray(); int i = aValidIndex(); elements[i] = null; collection = getSubjectGenerator().create(elements); doTestSet(samples.e3); }
@CollectionSize.Require(absent = ZERO) @CollectionFeature.Require(ALLOWS_NULL_VALUES) @ListFeature.Require(SUPPORTS_SET) public void testSet_replacingNull() { E[] elements = createSamplesArray(); int i = aValidIndex(); elements[i] = null; collection = getSubjectGenerator().create(elements); doTestSet(e3()); }