Exemplo n.º 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);
 }
Exemplo n.º 2
0
 public void LargeArrayNotFound()
 {
     Assert.AreEqual(
         SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 100, rotation: 13), val: 107),
         -1);
 }
Exemplo n.º 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);
 }
Exemplo n.º 4
0
 public void SingletonArrayFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 1, rotation: 2), val: 0), 0);
 }
Exemplo n.º 5
0
 public void SingletonArrayNotFound()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(GenerateRotatedSortedArray(length: 1, rotation: 1), val: 99), -1);
 }
Exemplo n.º 6
0
 public void EmptyArray()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(
                         GenerateRotatedSortedArray(length: 0, rotation: 0), val: 1), -1);
 }
Exemplo n.º 7
0
 public void NullArray()
 {
     Assert.AreEqual(SearchInSortedRotatedArray.Search(null, 1), -1);
 }