private void testInsert_sortedInput() {
   int x[] = generateRandomSortedArray();
   int n = generateRandomInteger();
   int r[] = Ex1a.insert(x, n);
   assertTrue(isSorted(r));
   assertTrue(x.length + 1 == r.length);
   int testedForLessThanN = -1;
   for (int i = 0; i < x.length; i++) {
     if (x[i] <= n) {
       assertTrue(x[i] == r[i]);
       testedForLessThanN = i;
     } else {
       assertTrue(x[i] == r[i + 1]);
     }
   }
   assertTrue(r[testedForLessThanN + 1] == n);
 }
  /** Test method for {@link testing.Ex1a#insert(int[], int)}. */
  @Test
  public void testInsert() {
    int[] x1 = {};
    int n1 = 0;
    int[] r1 = Ex1a.insert(x1, n1);
    int[] e1 = {0};
    assertArrayEquals(e1, r1);

    int[] x2 = {1};
    int n2 = 0;
    int[] r2 = Ex1a.insert(x2, n2);
    int[] e2 = {0, 1};
    assertArrayEquals(e2, r2);

    int[] x3 = {1, 3, 5};
    int n3 = 4;
    int[] r3 = Ex1a.insert(x3, n3);
    int[] e3 = {1, 3, 4, 5};
    assertArrayEquals(e3, r3);

    int[] x4 = {1, 3, 3, 5};
    int n4 = 4;
    int[] r4 = Ex1a.insert(x4, n4);
    int[] e4 = {1, 3, 3, 4, 5};
    assertArrayEquals(e4, r4);

    int[] x5 = {1, 2, 0};
    int n5 = 3;
    int[] r5 = Ex1a.insert(x5, n5);
    int[] e5 = {1, 2, 0, 3};
    assertArrayEquals(e5, r5);

    int[] x6 = {4, 3, 2};
    int n6 = 2;
    int[] r6 = Ex1a.insert(x6, n6);
    int[] e6 = {2, 4, 3, 2};
    assertArrayEquals(e6, r6);
  }