use of junit.framework.AssertionFailedError in project poi by apache.
the class TestCFRuleRecord method testReserializeRefNTokens.
/**
* tRefN and tAreaN tokens must be preserved when re-serializing conditional format formulas
*/
@Test
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);
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestColumnInfoRecord method testZeroResevedBytes_bug48332.
/**
* Some applications skip the last reserved field when writing {@link ColumnInfoRecord}s
* The attached file was apparently created by "SoftArtisans OfficeWriter for Excel".
* Excel reads that file OK and assumes zero for the value of the reserved field.
*/
public void testZeroResevedBytes_bug48332() {
// Taken from bugzilla attachment 24661 (offset 0x1E73)
byte[] inpData = HexRead.readFromString("7D 00 0A 00 00 00 00 00 D5 19 0F 00 02 00");
byte[] outData = HexRead.readFromString("7D 00 0C 00 00 00 00 00 D5 19 0F 00 02 00 00 00");
RecordInputStream in = TestcaseRecordInputStream.create(inpData);
ColumnInfoRecord cir;
try {
cir = new ColumnInfoRecord(in);
} catch (RuntimeException e) {
if (e.getMessage().equals("Unusual record size remaining=(0)")) {
throw new AssertionFailedError("Identified bug 48332");
}
throw e;
}
assertEquals(0, in.remaining());
assertArrayEquals(outData, cir.serialize());
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestViewFieldsRecord method testUnicodeFlag_bug46693.
public void testUnicodeFlag_bug46693() {
byte[] data = HexRead.readFromString("01 00 01 00 01 00 04 00 05 00 00 6D 61 72 63 6F");
RecordInputStream in = TestcaseRecordInputStream.create(ViewFieldsRecord.sid, data);
ViewFieldsRecord rec = new ViewFieldsRecord(in);
if (in.remaining() == 1) {
throw new AssertionFailedError("Identified bug 46693b");
}
assertEquals(0, in.remaining());
assertEquals(4 + data.length, rec.getRecordSize());
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestSharedValueManager method testPartiallyOverlappingRanges.
/**
* This bug happened when there were two or more shared formula ranges that overlapped. POI
* would sometimes associate formulas in the overlapping region with the wrong shared formula
*/
public void testPartiallyOverlappingRanges() {
Record[] records;
int attempt = 1;
do {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook(SAMPLE_FILE_NAME);
HSSFSheet sheet = wb.getSheetAt(0);
RecordInspector.getRecords(sheet, 0);
assertEquals("1+1", sheet.getRow(2).getCell(0).getCellFormula());
if ("1+1".equals(sheet.getRow(3).getCell(0).getCellFormula())) {
throw new AssertionFailedError("Identified bug - wrong shared formula record chosen" + " (attempt " + attempt + ")");
}
assertEquals("2+2", sheet.getRow(3).getCell(0).getCellFormula());
records = RecordInspector.getRecords(sheet, 0);
} while (attempt++ < MAX_ATTEMPTS);
int count = 0;
for (Record record : records) {
if (record instanceof SharedFormulaRecord) {
count++;
}
}
assertEquals(2, count);
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestSeriesTextRecord method testReserializeLongTitle.
public void testReserializeLongTitle() {
// Hex dump from bug 45784 attachment 22560 streamOffset=0x0CD1
byte[] data = HexRead.readFromString("00 00, " + "82 " + "01 " + "50 00 6C 00 61 00 73 00 6D 00 61 00 20 00 4C 00 " + "65 00 76 00 65 00 6C 00 73 00 20 00 6F 00 66 00 " + "20 00 4C 00 2D 00 30 00 30 00 30 00 31 00 31 00 " + "31 00 32 00 32 00 32 00 2D 00 33 00 33 00 33 00 " + "58 00 34 00 34 00 34 00 20 00 69 00 6E 00 20 00 " + "53 00 44 00 20 00 72 00 61 00 74 00 0A 00 50 00 " + "4F 00 20 00 33 00 2E 00 30 00 20 00 6D 00 67 00 " + "2F 00 6B 00 67 00 20 00 28 00 35 00 2E 00 30 00 " + "20 00 6D 00 4C 00 2F 00 6B 00 67 00 29 00 20 00 " + "69 00 6E 00 20 00 4D 00 65 00 74 00 68 00 6F 00 " + "63 00 65 00 6C 00 0A 00 49 00 56 00 20 00 30 00 " + "2E 00 35 00 20 00 6D 00 67 00 2F 00 6B 00 67 00 " + "20 00 28 00 31 00 2E 00 30 00 20 00 6D 00 4C 00 " + "2F 00 6B 00 67 00 29 00 20 00 69 00 6E 00 20 00 " + "36 00 30 00 25 00 20 00 50 00 45 00 47 00 20 00 " + "32 00 30 00 30 00 0A 00 46 00 20 00 3D 00 61 00 " + "62 00 63 00");
RecordInputStream in = TestcaseRecordInputStream.create(SeriesTextRecord.sid, data);
SeriesTextRecord str;
try {
str = new SeriesTextRecord(in);
} catch (RecordFormatException e) {
if (e.getCause() instanceof IllegalArgumentException) {
// "Bad requested string length (-126)"
throw new AssertionFailedError("Identified bug 45784a");
}
throw e;
}
if (str.getRecordSize() < 0) {
throw new AssertionFailedError("Identified bug 45784b");
}
byte[] ser;
try {
ser = str.serialize();
} catch (Exception e) {
throw new RuntimeException(e);
}
TestcaseRecordInputStream.confirmRecordEncoding(SeriesTextRecord.sid, data, ser);
}
Aggregations