public void NegTest2() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableTreeList.Create(iArray).ToBuilder(); Assert.Throws <ArgumentOutOfRangeException>(() => listObject.GetRange(6, -4)); }
public void NegTest3() { char[] iArray = { '#', ' ', '&', 'c', '1', '_', 'A' }; var listObject = ImmutableTreeList.Create(iArray).ToBuilder(); Assert.Throws <ArgumentException>(() => listObject.GetRange(4, 4)); }
public void TestCreateSingle() { Assert.NotNull(ImmutableTreeList.Create(1)); Assert.Single(ImmutableTreeList.Create(1)); Assert.NotSame(ImmutableTreeList.Create(1), ImmutableTreeList.Create(2)); Assert.Equal(1, ImmutableTreeList.Create(1)[0]); }
public void TestCreateEmpty() { Assert.NotNull(ImmutableTreeList.Create <int>()); Assert.Empty(ImmutableTreeList.Create <int>()); Assert.Same(ImmutableTreeList.Create <int>(), ImmutableTreeList.Create <int>()); Assert.NotSame(ImmutableTreeList.Create <string>(), ImmutableTreeList.Create <object>()); }
public void NegTest1() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableTreeList.Create(iArray); Action <int>?action = null; Assert.Throws <ArgumentNullException>(() => listObject.ForEach(action !)); }
public void PosTest4() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableTreeList.Create(iArray).ToBuilder(); ImmutableTreeList <int> listResult = listObject.GetRange(5, 0); Assert.NotNull(listResult); Assert.Empty(listResult); }
public void PosTest2() { string[] strArray = { "Hello", "wor", "l", "d" }; var listObject = ImmutableTreeList.Create(strArray); var myClass = new MyClass(); var action = new Action <string>(myClass.JoinStr); listObject.ForEach(action); Assert.Equal("Helloworld", myClass.Result); }
public void PosTest1() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableTreeList.Create(iArray); var myClass = new MyClass(); var action = new Action <int>(myClass.SumCalc); listObject.ForEach(action); Assert.Equal(40, myClass.Sum); }
public void TestICollectionInterface() { TestICollectionInterfaceImpl(ImmutableSortedTreeList.Create <int>(600, 601).ToBuilder(), supportsNullValues: false); TestICollectionInterfaceImpl(ImmutableSortedTreeList.Create <int?>(600, 601).ToBuilder(), supportsNullValues: true); TestICollectionInterfaceImpl(ImmutableSortedTreeList.Create <object>(600, 601).ToBuilder(), supportsNullValues: true); // Run the same set of tests on ImmutableTreeList<T> to ensure consistent behavior TestICollectionInterfaceImpl(ImmutableTreeList.Create <int>(600, 601).ToBuilder(), supportsNullValues: false); TestICollectionInterfaceImpl(ImmutableTreeList.Create <int?>(600, 601).ToBuilder(), supportsNullValues: true); TestICollectionInterfaceImpl(ImmutableTreeList.Create <object>(600, 601).ToBuilder(), supportsNullValues: true); }
public void TestToImmutableTreeList() { Assert.NotNull(new[] { 1, 5, 4 }.ToImmutableTreeList()); Assert.Equal(3, new[] { 1, 5, 4 }.ToImmutableTreeList().Count); Assert.Equal(new[] { 1, 5, 4 }, new[] { 1, 5, 4 }.ToImmutableTreeList()); // If the source is already an immutable tree list, the method simply returns the same instance IEnumerable <int> source = ImmutableTreeList.Create(1, 5, 4); Assert.Same(source, source.ToImmutableTreeList()); }
public void TestIListInterface() { TestIListInterfaceImpl(ImmutableTreeList.Create(600, 601), supportsNullValues: false); TestIListInterfaceImpl(ImmutableTreeList.Create <int?>(600, 601), supportsNullValues: true); TestIListInterfaceImpl(ImmutableTreeList.Create <object>(600, 601), supportsNullValues: true); // Run the same set of tests on List<T> to ensure consistent behavior TestIListInterfaceImpl(ImmutableList.Create(600, 601), supportsNullValues: false); TestIListInterfaceImpl(ImmutableList.Create <int?>(600, 601), supportsNullValues: true); TestIListInterfaceImpl(ImmutableList.Create <object>(600, 601), supportsNullValues: true); }
public void TestCreateBuilder() { Assert.NotNull(ImmutableTreeList.CreateBuilder <int>()); Assert.Empty(ImmutableTreeList.CreateBuilder <int>()); Assert.NotSame(ImmutableTreeList.CreateBuilder <int>(), ImmutableTreeList.CreateBuilder <int>()); var builder1 = ImmutableTreeList.CreateBuilder <int>(); var builder2 = ImmutableTreeList.CreateBuilder <int>(); Assert.Empty(builder1); builder1.Add(1); Assert.Single(builder1); Assert.Empty(builder2); }
public void PosTest2() { string[] strArray = { "apple", "banana", "chocolate", "dog", "food" }; var listObject = ImmutableTreeList.Create(strArray).ToBuilder(); int startIdx = Generator.GetInt32(0, 4); // The starting index of the section to make a shallow copy int endIdx = Generator.GetInt32(startIdx, 5); // The end index of the section to make a shallow copy int count = endIdx - startIdx + 1; ImmutableTreeList <string> listResult = listObject.GetRange(startIdx, count); for (int i = 0; i < count; i++) { Assert.Equal(strArray[i + startIdx], listResult[i]); } }
public void PosTest1() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableTreeList.Create(iArray).ToBuilder(); int startIdx = Generator.GetInt32(0, 9); // The starting index of the section to make a shallow copy int endIdx = Generator.GetInt32(startIdx, 10); // The end index of the section to make a shallow copy int count = endIdx - startIdx + 1; ImmutableTreeList <int> listResult = listObject.GetRange(startIdx, count); for (int i = 0; i < count; i++) { Assert.Equal(iArray[i + startIdx], listResult[i]); } }
public void PosTest3() { var myclass1 = new MyClass2('h'); var myclass2 = new MyClass2('='); var myclass3 = new MyClass2('&'); var mc = new MyClass2[3] { myclass1, myclass2, myclass3 }; var listObject = ImmutableTreeList.Create(mc); var myClass = new MyClass(); var action = new Action <MyClass2>(myClass.DeleteValue); listObject.ForEach(action); for (int i = 0; i < 3; i++) { Assert.Null(mc[i].Value); } }
public void PosTest3() { var myclass1 = new MyClass(); var myclass2 = new MyClass(); var myclass3 = new MyClass(); var mc = new MyClass[3] { myclass1, myclass2, myclass3 }; var listObject = ImmutableTreeList.Create(mc).ToBuilder(); int startIdx = Generator.GetInt32(0, 2); // The starting index of the section to make a shallow copy int endIdx = Generator.GetInt32(startIdx, 3); // The end index of the section to make a shallow copy int count = endIdx - startIdx + 1; ImmutableTreeList <MyClass> listResult = listObject.GetRange(startIdx, count); for (int i = 0; i < count; i++) { Assert.Equal(mc[i + startIdx], listResult[i]); } }
public void TestICollectionInterface() { TestICollectionInterfaceImpl(ImmutableTreeList.Create(600, 601).ToBuilder(), isOwnSyncRoot: true, supportsNullValues: false); TestICollectionInterfaceImpl(ImmutableTreeList.Create <int?>(600, 601).ToBuilder(), isOwnSyncRoot: true, supportsNullValues: true); TestICollectionInterfaceImpl(ImmutableTreeList.Create <object>(600, 601).ToBuilder(), isOwnSyncRoot: true, supportsNullValues: true); ICollection collection = ImmutableTreeList <int> .Empty.ToBuilder(); collection.CopyTo(new int[0], 0); // Type checks are only performed if the collection has items collection.CopyTo(new string[0], 0); collection = ImmutableTreeList.CreateRange(Enumerable.Range(0, 100)).ToBuilder(); var array = new int[collection.Count]; collection.CopyTo(array, 0); Assert.Equal(array, collection); // Run the same set of tests on ImmutableList<T>.Builder to ensure consistent behavior TestICollectionInterfaceImpl(ImmutableList.Create(600, 601).ToBuilder(), isOwnSyncRoot: false, supportsNullValues: false); TestICollectionInterfaceImpl(ImmutableList.Create <int?>(600, 601).ToBuilder(), isOwnSyncRoot: false, supportsNullValues: true); TestICollectionInterfaceImpl(ImmutableList.Create <object>(600, 601).ToBuilder(), isOwnSyncRoot: false, supportsNullValues: true); }
public ImmutableTreeList <int> TreeList() { return(ImmutableTreeList.CreateRange(Enumerable.Range(0, Count))); }
public void TestCreateMany() { Assert.NotNull(ImmutableTreeList.Create(1, 5, 4)); Assert.Equal(3, ImmutableTreeList.Create(1, 5, 4).Count); Assert.Equal(new[] { 1, 5, 4 }, ImmutableTreeList.Create(1, 5, 4)); }
public void TestTreeListConstructor() { ImmutableTreeList <int> .Builder list = ImmutableTreeList.CreateBuilder <int>(); Assert.Empty(list); }
public void TestCreateRange() { Assert.NotNull(ImmutableTreeList.CreateRange(new[] { 1, 5, 4 })); Assert.Equal(3, ImmutableTreeList.CreateRange(new[] { 1, 5, 4 }).Count); Assert.Equal(new[] { 1, 5, 4 }, ImmutableTreeList.CreateRange(new[] { 1, 5, 4 })); }