public void SearchOneItemInListWithMapAndComparerTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }; var val = Colls.BinarySearch(list, v => v + 1, 3, Comparer <int> .Default); val.ShouldBe(1); }
public void SearchOneItemInListWithMapTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }; var val = Colls.BinarySearch(list, v => v + 1, 3); // 2 + 1 = 3, so matched 2 val.ShouldBe(1); }
public void SearchOneItemInReadOnlyListWithComparerTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }.AsReadOnly(); var val = Colls.BinarySearch(list, 3, Comparer <int> .Default); val.ShouldBe(2); }
public void SearchOneItemInReadOnlyListTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }.AsReadOnly(); var val = Colls.BinarySearch(list, 3); val.ShouldBe(2); }
public void SearchOneItemInListWithStartAndLengthAndComparerTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }; var val1 = Colls.BinarySearch(list, 2, 1, 3, Comparer <int> .Default); var val2 = Colls.BinarySearch(list, 1, 1, 3, Comparer <int> .Default); var val3 = Colls.BinarySearch(list, 1, 3, 3, Comparer <int> .Default); var val4 = Colls.BinarySearch(list, 1, 1, 3, Comparer <int> .Default); var val5 = Colls.BinarySearch(list, 5, 1, 3, Comparer <int> .Default); val1.ShouldBe(2); val2.ShouldBeNegative(); val3.ShouldBe(2); val4.ShouldBeNegative(); val5.ShouldBeNegative(); }
public void SearchOneItemInListWithMapAndStartAndLengthTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }; var val1 = Colls.BinarySearch(list, 2, 1, v => v + 1, 4); // 3 + 1 = 4, so matched 3 var val2 = Colls.BinarySearch(list, 1, 1, v => v + 1, 4); // 3 + 1 = 4, so matched 3 var val3 = Colls.BinarySearch(list, 1, 3, v => v + 1, 4); // 3 + 1 = 4, so matched 3 var val4 = Colls.BinarySearch(list, 1, 1, v => v + 1, 4); // 3 + 1 = 4, so matched 3 var val5 = Colls.BinarySearch(list, 5, 1, v => v + 1, 4); // 3 + 1 = 4, so matched 3 val1.ShouldBe(2); val2.ShouldBeNegative(); val3.ShouldBe(2); val4.ShouldBeNegative(); val5.ShouldBeNegative(); }
public void SearchOneItemInReadOnlyListWithStartAndLengthTest() { var list = new List <int> { 1, 2, 3, 4, 5, 6, 7 }.AsReadOnly(); var val1 = Colls.BinarySearch(list, 2, 1, 3); var val2 = Colls.BinarySearch(list, 1, 1, 3); var val3 = Colls.BinarySearch(list, 1, 3, 3); var val4 = Colls.BinarySearch(list, 1, 1, 3); var val5 = Colls.BinarySearch(list, 5, 1, 3); val1.ShouldBe(2); val2.ShouldBeNegative(); val3.ShouldBe(2); val4.ShouldBeNegative(); val5.ShouldBeNegative(); }