Package org.waveprotocol.wave.model.testing.RandomDocOpGenerator

Examples of org.waveprotocol.wave.model.testing.RandomDocOpGenerator.RandomProvider.nextInt()


  }

  public void testNextIntThrowsIllegalArgumentException() {
    RandomProvider rp = RandomProviderImpl.ofSeed(42);
    try {
      rp.nextInt(0);
      fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success
    }
    try {
View Full Code Here


      fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success
    }
    try {
      rp.nextInt(0x80000000);
      fail("should throw IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
      // success
    }
  }
View Full Code Here

    for (int seed : NUMBERS) {
      for (int bound : new int[]{ 2, 3, 4, 7, 16, 33 }) {
        RandomProvider rp = RandomProviderImpl.ofSeed(seed);
        int counts[] = new int[bound];
        for (int i = 0; i < ITERATIONS; i++) {
          counts[rp.nextInt(bound)]++; // fails with index-out-of-range if nextInt goes wrong
        }
        for (int j = 0; j < bound; j++) {
          assertTrue("seed " + seed + ", bound " + bound + ", index " + j + ", count " + counts[j],
              counts[j] >= (1.0 - MAX_DEVIATION) / bound * ITERATIONS);
          assertTrue("seed " + seed + ", bound " + bound + ", index " + j + ", count " + counts[j],
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.