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 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 TestAddIfAbsent2() { CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); full.AddIfAbsent(three); Assert.IsTrue(full.Contains(three)); }
public void TestIndexOf2() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Assert.AreEqual(1, full.IndexOf(1, 0)); Assert.AreEqual(-1, full.IndexOf(1, 2)); }
public void TestContains() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Assert.IsTrue(full.Contains(1)); Assert.IsFalse(full.Contains(5)); }
public int LastIndexOf(E o) { SubListReadData b = read; int ind = CopyOnWriteArrayList <E> .LastIndexOf(o, b.Data, start, b.Size) - start; return(ind < 0 ? -1 : ind); }
public void TestClear() { CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); full.Clear(); Assert.AreEqual(0, full.Size()); }
public void TestRemove() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Assert.AreEqual(two, full.Remove(2).ToString()); Assert.AreEqual(2, full.Size()); }
public void TestAddIfAbsent() { CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); full.AddIfAbsent(1); Assert.AreEqual(SIZE, full.Size()); }
public void TestIsEmpty() { CopyOnWriteArrayList <Object> empty = new CopyOnWriteArrayList <Object>(); CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); Assert.IsTrue(empty.IsEmpty()); Assert.IsFalse(full.IsEmpty()); }
public void TestSize() { CopyOnWriteArrayList <Object> empty = new CopyOnWriteArrayList <Object>(); CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); Assert.AreEqual(SIZE, full.Size()); Assert.AreEqual(0, empty.Size()); }
public void TestLastIndexOf2() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); full.Add(one); full.Add(three); Assert.AreEqual(3, full.LastIndexOf(one, 4)); Assert.AreEqual(-1, full.LastIndexOf(three, 3)); }
public void TestClone() { CopyOnWriteArrayList <Object> l1 = PopulatedArray(SIZE); CopyOnWriteArrayList <Object> l2 = (CopyOnWriteArrayList <Object>)(l1.Clone()); Assert.AreEqual(l1, l2); l1.Clear(); Assert.IsFalse(l1.Equals(l2)); }
public void TestGet2IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.Add("asdasd"); c.Add("asdad"); c.Get(100); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestToArray() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); Object[] o = full.ToArray(); Assert.AreEqual(3, o.Length); Assert.AreEqual(0, o[0]); Assert.AreEqual(1, o[1]); Assert.AreEqual(2, o[2]); }
public void TestToString() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); String s = full.ToString(); for (int i = 0; i < 3; ++i) { Assert.IsTrue(s.IndexOf(i.ToString()) >= 0); } }
public void TestRemoveAll() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); ArrayList <Object> v = new ArrayList <Object>(); v.Add(1); v.Add(2); full.RemoveAll(v); Assert.AreEqual(1, full.Size()); }
public void TestAddAllAbsent() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); ArrayList <Object> v = new ArrayList <Object>(); v.Add(3); v.Add(4); v.Add(1); // will not Add this element full.AddAllAbsent(v); Assert.AreEqual(5, full.Size()); }
public void TestAddAll() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); ArrayList <Object> v = new ArrayList <Object>(); v.Add(three); v.Add(four); v.Add(five); full.AddAll(v); Assert.AreEqual(6, full.Size()); }
public void TestSubList3IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.SubList(3, 1); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestListIterator1IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.ListIterator(-1); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestAddAll1IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.AddAll(-1, new ArrayList <Object>()); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestRemove1IndexOutOfBounds() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.Remove(-1); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestSet1IndexOutOfBoundsException() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.Set(-1, "qwerty"); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public void TestContainsAll() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); ArrayList <Object> v = new ArrayList <Object>(); v.Add(1); v.Add(2); Assert.IsTrue(full.ContainsAll(v)); v.Add(6); Assert.IsFalse(full.ContainsAll(v)); }
public SubListImpl(CopyOnWriteArrayList <E> list, int fromIdx, int toIdx) { this.list = list; Object[] data = list.Data; int size = toIdx - fromIdx; CheckIndexExlusive(fromIdx, data.Length); CheckIndexInclusive(toIdx, data.Length); read = new SubListReadData(size, list.Data); start = fromIdx; }
public void TestIterator() { CopyOnWriteArrayList <Object> full = PopulatedArray(SIZE); Iterator <Object> i = full.Iterator(); int j; for (j = 0; i.HasNext; j++) { Assert.AreEqual(j, i.Next()); } Assert.AreEqual(SIZE, j); }
public void TestListIterator2() { CopyOnWriteArrayList <Object> full = PopulatedArray(3); ListIterator <Object> i = full.ListIterator(1); int j; for (j = 0; i.HasNext; j++) { Assert.AreEqual(j + 1, i.Next()); } Assert.AreEqual(2, j); }
public void TestSet2() { try { CopyOnWriteArrayList <Object> c = new CopyOnWriteArrayList <Object>(); c.Add("asdasd"); c.Add("asdad"); c.Set(100, "qwerty"); ShouldThrow(); } catch (IndexOutOfRangeException) {} }
public virtual Object Clone() { try { CopyOnWriteArrayList <E> thisClone = (CopyOnWriteArrayList <E>)base.MemberwiseClone(); thisClone.Data = this.Data; return(thisClone); } catch (NotSupportedException) { throw new ApplicationException("NotSupportedException is not expected here"); } }