/** test shuffling of short arrays */
  @Test(timeout = 3600000)
  public void testShortArrayShuffleDoesNotCrashAndDoesNotModifyUnrelatedContent() {
    final Random rand;
    short[] arrayA, arrayB;
    int arrayLength, loopEnd, startIndex, count, arrayIndex, testLoop, testIndex;

    rand = new Random();

    for (arrayLength = 0; arrayLength <= 75; arrayLength++) {
      arrayA = new short[arrayLength];
      arrayB = new short[arrayLength];

      for (arrayIndex = 0; arrayIndex < 5; arrayIndex++) {
        for (count = arrayLength; (--count) >= 0; ) {
          arrayA[count] = ((short) ((rand.nextInt() & 0xffff)));
        }

        for (startIndex = 0; startIndex < arrayLength; startIndex++) {

          loopEnd = ((2 * arrayLength) + 5);
          for (count = (-loopEnd); count <= loopEnd; count++) {
            System.arraycopy(arrayA, 0, arrayB, 0, arrayLength);
            Shuffle.shuffle(arrayB, startIndex, count, rand);

            if ((count >= (-1)) && (count <= 1)) {
              Assert.assertTrue(Arrays.equals(arrayA, arrayB));
            } else {
              if ((count > (-arrayLength)) && (count < arrayLength)) {
                for (testLoop = (arrayLength - Math.abs(count)); (--testLoop) >= 0; ) {
                  if (count > 0) {
                    testIndex = (testLoop + startIndex + count);
                  } else {
                    testIndex = ((startIndex + count) - testLoop);
                  }
                  testIndex =
                      ((((testIndex + arrayLength) % arrayLength) + arrayLength) % arrayLength);
                  Assert.assertEquals(
                      arrayA[testIndex], //
                      arrayB[testIndex]);
                }
              }
            }
          }
        }
      }
    }
  }