Beispiel #1
0
  @Test
  public void testReverse() {
    int[] a = new int[] {1, 3, 5, -3, 6, 7};
    int[] toReverse = Arrays.copyOf(a, a.length);

    RotateString.reverse(toReverse, 0, toReverse.length - 1);

    assertEquals(a.length, toReverse.length);

    for (int i = 0; i < a.length; i++) {
      assertEquals(a[i], toReverse[toReverse.length - 1 - i]);
    }
  }
Beispiel #2
0
 @Test
 public void testBubbleRotate() throws Exception {
   int[] a = new int[] {1, 2, 3, 4, 5, 6, 7};
   RotateString.bubbleRotate(a, 3);
   System.out.println(Arrays.toString(a));
 }
Beispiel #3
0
 @Test(expected = IllegalArgumentException.class)
 public void testReverseInExceptionForRightArgument() {
   int[] a = new int[] {1, 2};
   RotateString.reverse(a, 0, 3);
 }