예제 #1
0
 public void testReserialize() {
   byte[] data =
       HexRead.readFromString(
           ""
               + "20 00 00 01 0B 00 00 00 01 00 00 00 00 00 00 06 3B 00 00 00 00 02 00 00 00 09 00]");
   RecordInputStream in = TestcaseRecordInputStream.create(NameRecord.sid, data);
   NameRecord nr = new NameRecord(in);
   assertEquals(0x0020, nr.getOptionFlag());
   byte[] data2 = nr.serialize();
   TestcaseRecordInputStream.confirmRecordEncoding(NameRecord.sid, data, data2);
 }
  /** tRefN and tAreaN tokens must be preserved when re-serializing conditional format formulas */
  public void testReserializeRefNTokens() {

    RecordInputStream is = TestcaseRecordInputStream.create(CFRuleRecord.sid, DATA_REFN);
    CFRuleRecord rr = new CFRuleRecord(is);
    Ptg[] ptgs = rr.getParsedExpression1();
    assertEquals(3, ptgs.length);
    if (ptgs[0] instanceof RefPtg) {
      throw new AssertionFailedError("Identified bug 45234");
    }
    assertEquals(RefNPtg.class, ptgs[0].getClass());
    RefNPtg refNPtg = (RefNPtg) ptgs[0];
    assertTrue(refNPtg.isColRelative());
    assertTrue(refNPtg.isRowRelative());

    byte[] data = rr.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
  }