示例#1
0
 public void LargeArrayFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 100, rotation: 13), val: 99),
                     (99 + 13) % 100);
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 100, rotation: 13), val: 54),
                     (54 + 13) % 100);
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 101, rotation: 13), val: 99),
                     (99 + 13) % 101);
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 100, rotation: 13), val: 54),
                     (54 + 13) % 101);
 }
示例#2
0
 public void LargeArrayNotFound()
 {
     Assert.AreEqual(
         SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 100, rotation: 13), val: 107),
         -1);
 }
示例#3
0
 public void TwoItemArrayFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 2, rotation: 1), val: 0), 1);
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 2, rotation: 1), val: 1), 0);
 }
示例#4
0
 public void SingletonArrayFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 1, rotation: 2), val: 0), 0);
 }
示例#5
0
 public void SingletonArrayNotFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 1, rotation: 1), val: 99), -1);
 }
示例#6
0
 public void EmptyArray()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 0, rotation: 0), val: 1), -1);
 }
示例#7
0
 public void NullArray()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(null, 1), -1);
 }