public void PosTest5() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableSortedTreeList.Create(iArray); Assert.Same(listObject, listObject.GetRange(0, listObject.Count)); }
public void NegTest3() { char[] iArray = { '#', ' ', '&', 'c', '1', '_', 'A' }; var listObject = ImmutableSortedTreeList.Create(iArray); Assert.Throws <ArgumentException>(() => listObject.GetRange(4, 4)); }
public void TestMultipleElementList() { var values = new[] { Generator.GetInt32(), Generator.GetInt32(), Generator.GetInt32() }; // Construction using ImmutableSortedTreeList.Create var list = ImmutableSortedTreeList.Create(values); Assert.Equal(values.OrderBy(x => x), list); list = ImmutableSortedTreeList.Create <int>(comparer: null, values); Assert.Same(Comparer <int> .Default, list.Comparer); Assert.Equal(values.OrderBy(x => x), list); list = ImmutableSortedTreeList.Create(ReverseComparer <int> .Default, values); Assert.Same(ReverseComparer <int> .Default, list.Comparer); Assert.Equal(values.OrderByDescending(x => x), list); // Construction using ImmutableSortedTreeList.ToImmutableSortedTreeList list = values.ToImmutableSortedTreeList(); Assert.Same(Comparer <int> .Default, list.Comparer); Assert.Equal(values.OrderBy(x => x), list); list = values.ToImmutableSortedTreeList(comparer: null); Assert.Same(Comparer <int> .Default, list.Comparer); Assert.Equal(values.OrderBy(x => x), list); list = values.ToImmutableSortedTreeList(ReverseComparer <int> .Default); Assert.Same(ReverseComparer <int> .Default, list.Comparer); Assert.Equal(values.OrderByDescending(x => x), list); }
public void NegTest2() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableSortedTreeList.Create(iArray); Assert.Throws <ArgumentOutOfRangeException>(() => listObject.GetRange(6, -4)); }
public void TestEmptyImmutableSortedTreeList() { var list = ImmutableSortedTreeList.Create <int>(); Assert.Same(ImmutableSortedTreeList <int> .Empty, list); Assert.Empty(list); Assert.True(list.IsEmpty); }
public void NegTest1() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableSortedTreeList.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 = ImmutableSortedTreeList.Create(iArray); ImmutableSortedTreeList <int> listResult = listObject.GetRange(5, 0); Assert.NotNull(listResult); Assert.Empty(listResult); }
public void PosTest1() { int[] iArray = { 1, 9, 3, 6, -1, 8, 7, 1, 2, 4 }; var listObject = ImmutableSortedTreeList.Create(iArray); var myClass = new MyClass(); var action = new Action <int>(myClass.SumCalc); listObject.ForEach(action); Assert.Equal(40, myClass.Sum); }
public void PosTest2() { string[] strArray = { "Hello", "wor", "l", "d" }; var listObject = ImmutableSortedTreeList.Create(new ComparisonComparer <string>((x, y) => 0), strArray); var myClass = new MyClass(); var action = new Action <string>(myClass.JoinStr); listObject.ForEach(action); Assert.Equal("Helloworld", myClass.Result); }
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 PosTest2() { string[] strArray = { "apple", "banana", "chocolate", "dog", "food" }; var listObject = ImmutableSortedTreeList.Create(strArray); 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; ImmutableSortedTreeList <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 = ImmutableSortedTreeList.Create(new ComparisonComparer <int>((x, y) => 0), iArray); 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; ImmutableSortedTreeList <int> listResult = listObject.GetRange(startIdx, count); for (int i = 0; i < count; i++) { Assert.Equal(iArray[i + startIdx], listResult[i]); } }
public void TestSingleElementList() { var value = Generator.GetInt32(); var list = ImmutableSortedTreeList.Create(value); Assert.Equal(new[] { value }, list); Assert.False(list.IsEmpty); list = ImmutableSortedTreeList.Create(comparer: null, value); Assert.Same(Comparer <int> .Default, list.Comparer); Assert.Equal(new[] { value }, list); list = ImmutableSortedTreeList.Create(ReverseComparer <int> .Default, value); Assert.Same(ReverseComparer <int> .Default, list.Comparer); Assert.Equal(new[] { value }, list); }
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 = ImmutableSortedTreeList.Create(new ComparisonComparer <MyClass2>((x, y) => 0), 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 = ImmutableSortedTreeList.Create(new ComparisonComparer <MyClass>((x, y) => 0), mc); 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; ImmutableSortedTreeList <MyClass> listResult = listObject.GetRange(startIdx, count); for (int i = 0; i < count; i++) { Assert.Equal(mc[i + startIdx], listResult[i]); } }
public void TestImmutableSortedTreeListCreateValidation() { Assert.Throws <ArgumentNullException>("items", () => ImmutableSortedTreeList.Create(default(int[]) !)); Assert.Throws <ArgumentNullException>("items", () => ImmutableSortedTreeList.Create(Comparer <int> .Default, default(int[]) !)); }
public void TestIListInterface() { TestIListInterfaceImpl(ImmutableSortedTreeList.Create <int>(600, 601).ToBuilder(), supportsNullValues: false); TestIListInterfaceImpl(ImmutableSortedTreeList.Create <int?>(600, 601).ToBuilder(), supportsNullValues: true); TestIListInterfaceImpl(ImmutableSortedTreeList.Create <ValueType>(600, 601).ToBuilder(), supportsNullValues: true); }