コード例 #1
0
  public void testWrite() throws Exception {
    TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    spec.writeOut(out);

    byte[] result = out.toByteArray();
    assertTrue(Arrays.equals(result, data_1));
  }
コード例 #2
0
  public void testRead() {
    TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
    TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
    assertEquals(5, run.length);

    assertEquals(10, run[0].length());
    assertEquals(1, run[1].length());
    assertEquals(70, run[2].length());
    assertEquals(9, run[3].length());
    assertEquals(32, run[4].length());
  }
コード例 #3
0
  public void testReset() throws Exception {
    TextSpecInfoAtom spec = new TextSpecInfoAtom(data_1, 0, data_1.length);
    spec.reset(32); // length of the parent text

    TextSpecInfoAtom.TextSpecInfoRun[] run = spec.getTextSpecInfoRuns();
    assertEquals(1, run.length);

    assertEquals(32, run[0].length());

    // serialize and read again
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    spec.writeOut(out);

    byte[] result = out.toByteArray();
    TextSpecInfoAtom spec2 = new TextSpecInfoAtom(result, 0, result.length);
    TextSpecInfoAtom.TextSpecInfoRun[] run2 = spec2.getTextSpecInfoRuns();
    assertEquals(1, run2.length);

    assertEquals(32, run2[0].length());
  }