public void Test() { Assert.IsTrue(IC.SetEq(list.UniqueItems())); Assert.IsTrue(IC.SetEq(list.ItemMultiplicities())); list.AddAll(new int[] { 7, 9, 7 }); Assert.IsTrue(IC.SetEq(list.UniqueItems(), 7, 9)); Assert.IsTrue(IC.SetEq(list.ItemMultiplicities(), 7, 2, 9, 1)); }
public void AddAll() { hashbag.Add(3); hashbag.Add(4); hashbag.Add(4); hashbag.Add(5); hashbag.Add(4); HashBag <int> hashbag2 = new HashBag <int>(); hashbag2.AddAll(hashbag); Assert.IsTrue(IC.SetEq(hashbag2, 3, 4, 4, 4, 5)); hashbag.Add(9); hashbag.AddAll(hashbag2); Assert.IsTrue(IC.SetEq(hashbag2, 3, 4, 4, 4, 5)); Assert.IsTrue(IC.SetEq(hashbag, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 9)); }
public void AddAll() { hashset.Add(3); hashset.Add(4); hashset.Add(5); HashSet <int> hashset2 = new HashSet <int>(); hashset2.AddAll(hashset); Assert.IsTrue(IC.SetEq(hashset2, 3, 4, 5)); hashset.Add(9); hashset.AddAll(hashset2); Assert.IsTrue(IC.SetEq(hashset2, 3, 4, 5)); Assert.IsTrue(IC.SetEq(hashset, 3, 4, 5, 9)); }
public void RetainAll() { HashBag <int> list2 = new HashBag <int>(); hashbag.Add(4); hashbag.Add(5); hashbag.Add(4); hashbag.Add(6); hashbag.Add(4); list2.Add(5); list2.Add(4); list2.Add(7); list2.Add(4); hashbag.RetainAll(list2); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 5)); hashbag.Add(6); list2.Clear(); list2.Add(7); list2.Add(8); list2.Add(9); hashbag.RetainAll(list2); Assert.IsTrue(IC.Eq(hashbag)); }
public void RetainAll() { HashSet <int> list2 = new HashSet <int>(); hashset.Add(4); hashset.Add(5); hashset.Add(6); list2.Add(5); list2.Add(4); list2.Add(7); hashset.RetainAll(list2); Assert.IsTrue(IC.SetEq(hashset, 4, 5)); hashset.Add(6); list2.Clear(); list2.Add(7); list2.Add(8); list2.Add(9); hashset.RetainAll(list2); Assert.IsTrue(IC.SetEq(hashset)); }
public void Many() { int j = 7373; int[] a = new int[j]; for (int i = 0; i < j; i++) { hashset.Add(3 * i + 1); a[i] = 3 * i + 1; } Assert.IsTrue(IC.SetEq(hashset, a)); }
public void Normal() { hashset.Add(5); hashset.Add(8); hashset.Add(5); hashset.Add(5); hashset.Add(10); hashset.Add(1); hashset.Add(16); hashset.Add(18); hashset.Add(17); hashset.Add(33); Assert.IsTrue(IC.SetEq(hashset, 1, 5, 8, 10, 16, 17, 18, 33)); }
public void Remove() { hashset.Add(4); hashset.Add(4); hashset.Add(5); hashset.Add(4); hashset.Add(6); Assert.IsFalse(hashset.Remove(2)); Assert.IsTrue(hashset.Remove(4)); Assert.IsTrue(IC.SetEq(hashset, 5, 6)); hashset.Add(7); hashset.Add(21); hashset.Add(37); hashset.Add(53); hashset.Add(69); hashset.Add(85); Assert.IsTrue(hashset.Remove(5)); Assert.IsTrue(IC.SetEq(hashset, 6, 7, 21, 37, 53, 69, 85)); Assert.IsFalse(hashset.Remove(165)); Assert.IsTrue(IC.SetEq(hashset, 6, 7, 21, 37, 53, 69, 85)); Assert.IsTrue(hashset.Remove(53)); Assert.IsTrue(IC.SetEq(hashset, 6, 7, 21, 37, 69, 85)); Assert.IsTrue(hashset.Remove(37)); Assert.IsTrue(IC.SetEq(hashset, 6, 7, 21, 69, 85)); Assert.IsTrue(hashset.Remove(85)); Assert.IsTrue(IC.SetEq(hashset, 6, 7, 21, 69)); }
public void Remove() { hashbag.Add(4); hashbag.Add(4); hashbag.Add(5); hashbag.Add(4); hashbag.Add(6); Assert.IsFalse(hashbag.Remove(2)); Assert.IsTrue(hashbag.Remove(4)); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 5, 6)); hashbag.Add(7); hashbag.Add(21); hashbag.Add(37); hashbag.Add(53); hashbag.Add(69); hashbag.Add(53); hashbag.Add(85); Assert.IsTrue(hashbag.Remove(5)); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 6, 7, 21, 37, 53, 53, 69, 85)); Assert.IsFalse(hashbag.Remove(165)); Assert.IsTrue(hashbag.Check()); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 6, 7, 21, 37, 53, 53, 69, 85)); Assert.IsTrue(hashbag.Remove(53)); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 6, 7, 21, 37, 53, 69, 85)); Assert.IsTrue(hashbag.Remove(37)); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 6, 7, 21, 53, 69, 85)); Assert.IsTrue(hashbag.Remove(85)); Assert.IsTrue(IC.SetEq(hashbag, 4, 4, 6, 7, 21, 53, 69)); }
public void View() { int[] inner = new int[] { 3, 4, 6, 5, 7 }; WrappedArray <int> outerwrapped = new WrappedArray <int>(inner); WrappedArray <int> wrapped = (WrappedArray <int>)outerwrapped.View(1, 3); // Assert.AreEqual(6, wrapped[1]); Assert.IsTrue(IC.Eq(wrapped[1, 2], 6, 5)); // bool is4(int i) { return(i == 4); } Assert.AreEqual(EventType.None, wrapped.ActiveEvents); Assert.AreEqual(false, wrapped.All(is4)); Assert.AreEqual(true, wrapped.AllowsDuplicates); wrapped.Apply(delegate(int i) { }); Assert.AreEqual("{ 5, 6, 4 }", wrapped.Backwards().ToString()); Assert.AreEqual(true, wrapped.Check()); wrapped.Choose(); Assert.AreEqual(true, wrapped.Contains(4)); Assert.AreEqual(true, wrapped.ContainsAll(new ArrayList <int>())); Assert.AreEqual(1, wrapped.ContainsCount(4)); Assert.AreEqual(Speed.Linear, wrapped.ContainsSpeed); int[] extarray = new int[5]; wrapped.CopyTo(extarray, 1); Assert.IsTrue(IC.Eq(extarray, 0, 4, 6, 5, 0)); Assert.AreEqual(3, wrapped.Count); Assert.AreEqual(Speed.Constant, wrapped.CountSpeed); Assert.AreEqual(EnumerationDirection.Forwards, wrapped.Direction); Assert.AreEqual(false, wrapped.DuplicatesByCounting); Assert.AreEqual(System.Collections.Generic.EqualityComparer <int> .Default, wrapped.EqualityComparer); Assert.AreEqual(true, wrapped.Exists(is4)); Assert.IsTrue(IC.Eq(wrapped.Filter(is4), 4)); int j = 5; Assert.AreEqual(true, wrapped.Find(ref j)); Assert.AreEqual(true, wrapped.Find(is4, out j)); Assert.AreEqual("[ 0:4 ]", wrapped.FindAll(is4).ToString()); Assert.AreEqual(0, wrapped.FindIndex(is4)); Assert.AreEqual(true, wrapped.FindLast(is4, out j)); Assert.AreEqual(0, wrapped.FindLastIndex(is4)); Assert.AreEqual(4, wrapped.First); wrapped.GetEnumerator(); Assert.AreEqual(CHC.SequencedHashCode(4, 6, 5), wrapped.GetSequencedHashCode()); Assert.AreEqual(CHC.UnsequencedHashCode(4, 6, 5), wrapped.GetUnsequencedHashCode()); Assert.AreEqual(Speed.Constant, wrapped.IndexingSpeed); Assert.AreEqual(2, wrapped.IndexOf(5)); Assert.AreEqual(false, wrapped.IsEmpty); Assert.AreEqual(true, wrapped.IsReadOnly); Assert.AreEqual(false, wrapped.IsSorted()); Assert.AreEqual(true, wrapped.IsValid); Assert.AreEqual(5, wrapped.Last); Assert.AreEqual(2, wrapped.LastIndexOf(5)); Assert.AreEqual(EventType.None, wrapped.ListenableEvents); string i2s(int i) { return(string.Format("T{0}", i)); } Assert.AreEqual("[ 0:T4, 1:T6, 2:T5 ]", wrapped.Map <string>(i2s).ToString()); Assert.AreEqual(1, wrapped.Offset); wrapped.Reverse(); Assert.AreEqual("[ 0:5, 1:6, 2:4 ]", wrapped.ToString()); IList <int> other = new ArrayList <int>(); other.AddAll(new int[] { 4, 5, 6 }); Assert.IsFalse(wrapped.SequencedEquals(other)); j = 30; Assert.AreEqual(true, wrapped.Show(new System.Text.StringBuilder(), ref j, null)); wrapped.Sort(); Assert.AreEqual("[ 0:4, 1:5, 2:6 ]", wrapped.ToString()); Assert.IsTrue(IC.Eq(wrapped.ToArray(), 4, 5, 6)); Assert.AreEqual("[ ... ]", wrapped.ToString("L4", null)); // TODO: Below line removed as NUnit 3.0 test fails trying to enumerate... // Assert.AreEqual(outerwrapped, wrapped.Underlying); Assert.IsTrue(IC.SetEq(wrapped.UniqueItems(), 4, 5, 6)); Assert.IsTrue(wrapped.UnsequencedEquals(other)); // Assert.IsTrue(wrapped.TrySlide(1)); Assert.IsTrue(IC.Eq(wrapped, 5, 6, 7)); Assert.IsTrue(wrapped.TrySlide(-1, 2)); Assert.IsTrue(IC.Eq(wrapped, 4, 5)); Assert.IsFalse(wrapped.TrySlide(-2)); Assert.IsTrue(IC.Eq(wrapped.Span(outerwrapped.ViewOf(7)), 4, 5, 6, 7)); // wrapped.Shuffle(); Assert.IsTrue(IC.SetEq(wrapped.UniqueItems(), 4, 5)); Assert.IsTrue(wrapped.IsValid); wrapped.Dispose(); Assert.IsFalse(wrapped.IsValid); }