public void testSyntheticWithBytesNew() throws IOException {
    // pass seed, to keep results consistent:
    final int SEED = 33333;
    ByteQuadsCanonicalizer symbols =
        ByteQuadsCanonicalizer.createRoot(SEED).makeChild(JsonFactory.Feature.collectDefaults());

    final int COUNT = 12000;
    for (int i = 0; i < COUNT; ++i) {
      String id = fieldNameFor(i);
      int[] quads = calcQuads(id.getBytes("UTF-8"));
      symbols.addName(id, quads, quads.length);
    }
    assertEquals(COUNT, symbols.size());
    assertEquals(16384, symbols.bucketCount());

    // fragile, but essential to verify low collision counts;
    // anywhere between 70-80% primary matches
    assertEquals(8534, symbols.primaryCount());
    // secondary between 10-20%
    assertEquals(2534, symbols.secondaryCount());
    // and most of remaining in tertiary
    assertEquals(932, symbols.tertiaryCount());
    // so that spill-over is empty or close to
    assertEquals(0, symbols.spilloverCount());
  }
  public void testShortNameCollisionsDirectNew() throws IOException {
    final int COUNT = 700;
    {
      ByteQuadsCanonicalizer symbols =
          ByteQuadsCanonicalizer.createRoot(333).makeChild(JsonFactory.Feature.collectDefaults());
      for (int i = 0; i < COUNT; ++i) {
        String id = String.valueOf((char) i);
        int[] quads = calcQuads(id.getBytes("UTF-8"));
        symbols.addName(id, quads, quads.length);
      }
      assertEquals(COUNT, symbols.size());

      assertEquals(1024, symbols.bucketCount());

      // Primary is good, but secondary spills cluster in nasty way...
      assertEquals(564, symbols.primaryCount());
      assertEquals(122, symbols.secondaryCount());
      assertEquals(14, symbols.tertiaryCount());
      assertEquals(0, symbols.spilloverCount());

      assertEquals(
          COUNT,
          symbols.primaryCount()
              + symbols.secondaryCount()
              + symbols.tertiaryCount()
              + symbols.spilloverCount());
    }
  }
  public void testShortQuotedDirectBytes() throws IOException {
    final int COUNT = 400;
    ByteQuadsCanonicalizer symbols =
        ByteQuadsCanonicalizer.createRoot(123).makeChild(JsonFactory.Feature.collectDefaults());
    for (int i = 0; i < COUNT; ++i) {
      String id = String.format("\\u%04x", i);
      int[] quads = calcQuads(id.getBytes("UTF-8"));
      symbols.addName(id, quads, quads.length);
    }
    assertEquals(COUNT, symbols.size());
    assertEquals(512, symbols.bucketCount());

    assertEquals(285, symbols.primaryCount());
    assertEquals(90, symbols.secondaryCount());
    assertEquals(25, symbols.tertiaryCount());
    assertEquals(0, symbols.spilloverCount());
  }
  // Another variant, but with 1-quad names
  public void testCollisionsWithBytesNew187b() throws IOException {
    ByteQuadsCanonicalizer symbols =
        ByteQuadsCanonicalizer.createRoot(1).makeChild(JsonFactory.Feature.collectDefaults());

    final int COUNT = 10000;
    for (int i = 0; i < COUNT; ++i) {
      String id = String.valueOf(i);
      int[] quads = calcQuads(id.getBytes("UTF-8"));
      symbols.addName(id, quads, quads.length);
    }
    assertEquals(COUNT, symbols.size());

    assertEquals(16384, symbols.bucketCount());

    // fragile, but essential to verify low collision counts;
    // here bit low primary, 55%
    assertEquals(5402, symbols.primaryCount());
    // secondary higher than usual, above 25%
    assertEquals(2744, symbols.secondaryCount());
    // and most of remaining in tertiary
    assertEquals(1834, symbols.tertiaryCount());
    // with a bit of spillover
    assertEquals(20, symbols.spilloverCount());
  }
  // [core#187]: unexpectedly high number of collisions for straight numbers
  public void testCollisionsWithBytesNew187a() throws IOException {
    ByteQuadsCanonicalizer symbols =
        ByteQuadsCanonicalizer.createRoot(1).makeChild(JsonFactory.Feature.collectDefaults());

    final int COUNT = 43000;
    for (int i = 0; i < COUNT; ++i) {
      String id = String.valueOf(10000 + i);
      int[] quads = calcQuads(id.getBytes("UTF-8"));
      symbols.addName(id, quads, quads.length);
    }

    assertEquals(COUNT, symbols.size());
    assertEquals(65536, symbols.bucketCount());

    /* 29-Mar-2015, tatu: To get collision counts down for this
     *    test took quite a bit of tweaking...
     */
    assertEquals(32342, symbols.primaryCount());
    assertEquals(8863, symbols.secondaryCount());
    assertEquals(1795, symbols.tertiaryCount());

    // finally managed to get this to 0; other variants produced thousands
    assertEquals(0, symbols.spilloverCount());
  }