public void TestAddAll() { ShortList list = new ShortList(); for (short j = 0; j < 5; j++) { list.Add(j); } ShortList list2 = new ShortList(0); list2.AddAll(list); list2.AddAll(list); Assert.AreEqual(2 * list.Count, list2.Count); for (short j = 0; j < 5; j++) { Assert.AreEqual(list2.Get(j), j); Assert.AreEqual(list2.Get(j + list.Count), j); } ShortList empty = new ShortList(); int limit = list.Count; for (int j = 0; j < limit; j++) { Assert.IsTrue(list.AddAll(j, empty)); Assert.AreEqual(limit, list.Count); } try { list.AddAll(limit + 1, empty); Assert.Fail("should have thrown an exception"); } catch (IndexOutOfRangeException) { // as expected } // try add at beginning empty.AddAll(0, list); //Assert.AreEqual(empty, list); Assert.IsTrue(empty.Equals(list)); // try in the middle empty.AddAll(1, list); Assert.AreEqual(2 * list.Count, empty.Count); Assert.AreEqual(list.Get(0), empty.Get(0)); Assert.AreEqual(list.Get(0), empty.Get(1)); Assert.AreEqual(list.Get(1), empty.Get(2)); Assert.AreEqual(list.Get(1), empty.Get(6)); Assert.AreEqual(list.Get(2), empty.Get(3)); Assert.AreEqual(list.Get(2), empty.Get(7)); Assert.AreEqual(list.Get(3), empty.Get(4)); Assert.AreEqual(list.Get(3), empty.Get(8)); Assert.AreEqual(list.Get(4), empty.Get(5)); Assert.AreEqual(list.Get(4), empty.Get(9)); // try at the end empty.AddAll(empty.Count, list); Assert.AreEqual(3 * list.Count, empty.Count); Assert.AreEqual(list.Get(0), empty.Get(0)); Assert.AreEqual(list.Get(0), empty.Get(1)); Assert.AreEqual(list.Get(0), empty.Get(10)); Assert.AreEqual(list.Get(1), empty.Get(2)); Assert.AreEqual(list.Get(1), empty.Get(6)); Assert.AreEqual(list.Get(1), empty.Get(11)); Assert.AreEqual(list.Get(2), empty.Get(3)); Assert.AreEqual(list.Get(2), empty.Get(7)); Assert.AreEqual(list.Get(2), empty.Get(12)); Assert.AreEqual(list.Get(3), empty.Get(4)); Assert.AreEqual(list.Get(3), empty.Get(8)); Assert.AreEqual(list.Get(3), empty.Get(13)); Assert.AreEqual(list.Get(4), empty.Get(5)); Assert.AreEqual(list.Get(4), empty.Get(9)); Assert.AreEqual(list.Get(4), empty.Get(14)); }