public void Reverse() { var mutable = ImmutableTrieList.CreateRange(Enumerable.Range(1, 3)).ToBuilder(); mutable.Reverse(); Assert.Equal(Enumerable.Range(1, 3).Reverse(), mutable); }
public void IndexOf() { IndexOfTests.IndexOfTest( seq => ImmutableTrieList.CreateRange(seq).ToBuilder(), (b, v) => b.IndexOf(v), (b, v, i) => b.IndexOf(v, i), (b, v, i, c) => b.IndexOf(v, i, c), (b, v, i, c, eq) => b.IndexOf(v, i, c, eq)); }
public void LastIndexOf() { IndexOfTests.LastIndexOfTest( seq => ImmutableTrieList.CreateRange(seq).ToBuilder(), (b, v) => b.LastIndexOf(v), (b, v, eq) => b.LastIndexOf(v, b.Count > 0 ? b.Count - 1 : 0, b.Count, eq), (b, v, i) => b.LastIndexOf(v, i), (b, v, i, c) => b.LastIndexOf(v, i, c), (b, v, i, c, eq) => b.LastIndexOf(v, i, c, eq)); }
public void GetRangeExceptionTest() { const int count = 100; var list = ImmutableTrieList.CreateRange(Enumerable.Range(0, count)); Assert.Throws <ArgumentOutOfRangeException>(() => list.GetRange(-1, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => list.GetRange(0, -1)); Assert.Throws <ArgumentException>(() => list.GetRange(count + 1, 0)); Assert.Throws <ArgumentException>(() => list.GetRange(count, 1)); Assert.Throws <ArgumentException>(() => list.GetRange(0, count + 1)); }
public void Clear() { var mutable = ImmutableTrieList.CreateRange(Enumerable.Range(1, 3)).ToBuilder(); mutable.Clear(); Assert.Equal(0, mutable.Count); // Do it again for good measure. :) mutable.Clear(); Assert.Equal(0, mutable.Count); }
public void PopTest() { int count = 1025; // 2^10 + 1 var list = ImmutableTrieList.CreateRange(Enumerable.Range(0, count)); Assert.Equal(Enumerable.Range(0, count), list); for (int i = count - 1; i >= 0; i--) { list = list.Pop(); Assert.Equal(Enumerable.Range(0, i), list); } }
public void Indexer() { var list = ImmutableTrieList.CreateRange(Enumerable.Range(1, 3)); Assert.Equal(1, list[0]); Assert.Equal(2, list[1]); Assert.Equal(3, list[2]); Assert.Throws <ArgumentOutOfRangeException>("index", () => list[3]); Assert.Throws <ArgumentOutOfRangeException>("index", () => list[-1]); Assert.Equal(3, ((IList)list)[2]); Assert.Equal(3, ((IList <int>)list)[2]); }
public void IndexOf() { IndexOfTests.IndexOfTest( seq => ImmutableTrieList.CreateRange(seq), (b, v) => b.IndexOf(v), (b, v, i) => b.IndexOf(v, i), (b, v, i, c) => b.IndexOf(v, i, c), (b, v, i, c, eq) => b.IndexOf(v, i, c, eq)); IndexOfTests.IndexOfTest( seq => (IImmutableList <int>)ImmutableTrieList.CreateRange(seq), (b, v) => b.IndexOf(v), (b, v, i) => b.IndexOf(v, i), (b, v, i, c) => b.IndexOf(v, i, c), (b, v, i, c, eq) => b.IndexOf(v, i, c, eq)); }
public void ChangesAfterToImmutable() { var mutable = ImmutableTrieList.CreateRange(Enumerable.Range(0, 25)).ToBuilder(); var immutable1 = mutable.ToImmutable(); Assert.Same(immutable1, mutable.ToImmutable()); //, "The Immutable property getter is creating new objects without any differences."); mutable.Add(-1); var immutable2 = mutable.ToImmutable(); mutable.Add(-2); mutable[0] = -3; Assert.Equal(27, mutable.Count); Assert.Equal(26, immutable2.Count); }
public void Indexer() { var mutable = ImmutableTrieList.CreateRange(Enumerable.Range(1, 3)).ToBuilder(); Assert.Equal(2, mutable[1]); mutable[1] = 5; Assert.Equal(5, mutable[1]); mutable[0] = -2; mutable[2] = -3; Assert.Equal(new[] { -2, 5, -3 }, mutable); Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[3] = 4); Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[-1] = 4); Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[3]); Assert.Throws <ArgumentOutOfRangeException>("index", () => mutable[-1]); }
public void Create() { var comparer = StringComparer.OrdinalIgnoreCase; ImmutableTrieList <string> list = ImmutableTrieList.Create <string>(); Assert.Equal(0, list.Count); list = ImmutableTrieList.Create("a"); Assert.Equal(1, list.Count); list = ImmutableTrieList.Create("a", "b"); Assert.Equal(2, list.Count); list = ImmutableTrieList.CreateRange((IEnumerable <string>) new[] { "a", "b" }); Assert.Equal(2, list.Count); }