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

Examples of org.waveprotocol.wave.model.testing.RandomDocOpGenerator.RandomProvider


    Parameters p = new Parameters();
    for (int i = 0; i < 200; i++) {
      BootstrapDocument doc = new BootstrapDocument();
      for (int j = 0; j < 20; j++) {
        RandomProvider ra = RandomProviderImpl.ofSeed(i * 20 + j);
        RandomProvider rb = RandomProviderImpl.ofSeed(i * 20 + j + 1);
        DocOp a = RandomDocOpGenerator.generate(ra, p, doc);
        DocOp b = RandomDocOpGenerator.generate(rb, p, doc);
        doc.consume(a);
        assertTrue(eq.equal(a, a));
        // The combination of RandomProvider and RandomDocOpGenerator doesn't
View Full Code Here


public class DocOpGenerator implements RandomOpGenerator<BootstrapDocument, DocOp> {

  // TODO: replace the argument with RandomProvider to make this work in GWT
  @Override
  public DocOp randomOperation(BootstrapDocument state, final Random random) {
    RandomProvider randomProvider = new RandomProvider() {
      @Override
      public boolean nextBoolean() {
        return random.nextBoolean();
      }
View Full Code Here

  public void testNextInt1() {
    assertEquals(0, RandomProviderImpl.ofSeed(42).nextInt(1));
  }

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

  }

  public void testNextIntDistribution() {
    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

    }
  }

  public void testNextBooleanDistribution() {
    for (int seed : NUMBERS) {
      RandomProvider rp = RandomProviderImpl.ofSeed(seed);
      int trueCount = 0;
      for (int i = 0; i < ITERATIONS; i++) {
        if (rp.nextBoolean()) {
          trueCount++;
        }
      }
      assertTrue("seed " + seed + ", trueCount " + trueCount,
          trueCount >= (1.0 - MAX_DEVIATION) * 0.5 * ITERATIONS);
 
View Full Code Here

  private int iteration;

  public void testConsumeMethods() throws OperationException {
    IndexedDocumentImpl.performValidation = false;
    try {
      RandomProvider r = new RandomProviderImpl(1);
      for (RandomDocOpGenerator.Parameters params : PARAM_SETS) {
        for (iteration = 0; iteration < NUM_RUNS; iteration++) {
          System.out.println(iteration);
          consumeMethodsTestOneRun(r, params);
        }
View Full Code Here

  }

  /** For performance testing
   * @throws OperationException */
  public static void main(String[] argv) throws OperationException {
    RandomProvider random = new RandomProviderImpl(1);
    RandomDocOpGenerator.Parameters params = PARAM_SETS[0];
    DocumentSchema constraints = DocumentSchema.NO_SCHEMA_CONSTRAINTS;
    IndexedDocument<Node, Element, Text> doc =
      new IndexedDocumentImpl<Node, Element, Text, Void>(RawDocumentImpl.PROVIDER.parse("<a></a>"),
          new AnnotationTree<Object>("a", "b", null), constraints);
View Full Code Here

*/

public class PojoAnnotationPainterRandomLargeTest extends AnnotationPainterRandomTestBase {

  public PojoAnnotationPainterRandomLargeTest() {
    super(AnnotationPainterRandomTestBase.JUNIT_TEST_CONFIG, new RandomProvider() {
      final Random r = new Random(1);
      @Override
      public boolean nextBoolean() {
        return r.nextBoolean();
      }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.testing.RandomDocOpGenerator.RandomProvider

Copyright © 2018 www.massapicom. 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.