public void TestAddIndex() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); full.Add(0, m1); Assert.AreEqual(4, full.Size()); Assert.AreEqual(m1, full.Get(0)); Assert.AreEqual(zero, full.Get(1).ToString()); full.Add(2, m2); Assert.AreEqual(5, full.Size()); Assert.AreEqual(m2, full.Get(2)); Assert.AreEqual(two, full.Get(4).ToString()); }
public void TestSubList() { CopyOnWriteArrayList <Object> a = PopulatedArray(10); Assert.IsTrue(a.SubList(1, 1).IsEmpty()); for (int j = 0; j < 9; ++j) { for (int i = j; i < 10; ++i) { List <Object> b = a.SubList(j, i); for (int k = j; k < i; ++k) { Assert.AreEqual(k, b.Get(k - j)); } } } List <Object> s = a.SubList(2, 5); Assert.AreEqual(s.Size(), 3); s.Set(2, m1); Assert.AreEqual(a.Get(4), m1); s.Clear(); Assert.AreEqual(a.Size(), 7); }
public void TestSet() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Assert.AreEqual(two, full.Set(2, four).ToString()); Assert.AreEqual(4.ToString(), full.Get(2)); }
public void TestGet2IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.Add("asdasd"); c.Add("asdad"); c.Get(100); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestConstructor3() { Object[] ints = new Object[SIZE]; for (int i = 0; i < SIZE - 1; ++i) { ints[i] = i; } CopyOnWriteArrayList <Object> a = new CopyOnWriteArrayList <Object>(Arrays.AsList(ints)); for (int i = 0; i < SIZE; ++i) { Assert.AreEqual(ints[i], a.Get(i)); } }
public void TestGet() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Assert.AreEqual(0, full.Get(0)); }