public void TestVisioDrawing_bug46199() { /** * taken from ftPictFmla sub-record in attachment 22860 (stream offset 0x768F).<br/> * Note that the since the string length is zero, there is no unicode flag byte */ byte[] data46199 = hr( "0E 00 " + "05 00 " + "28 25 A3 01 " + "02 6C D1 34 02 " + "03 00 00 " + "0F CB E8 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(EORSR_SID, data46199); EmbeddedObjectRefSubRecord rec; try { rec = new EmbeddedObjectRefSubRecord(in1, data46199.Length); } catch (RecordFormatException e) { if (e.Message.Equals("Not enough data (3) to read requested (4) bytes")) { throw new AssertionException("Identified bug 22860"); } throw e; } byte[] ser2 = rec.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(EORSR_SID, data46199, ser2); }
public void TestLoad() { LegendRecord record = new LegendRecord(TestcaseRecordInputStream.Create((short)0x1015, data)); Assert.AreEqual((int)0xe76, record.XAxisUpperLeft); Assert.AreEqual((int)0x786, record.YAxisUpperLeft); Assert.AreEqual((int)0x119, record.XSize); Assert.AreEqual((int)0x8b, record.YSize); Assert.AreEqual((byte)0x3, record.Type); Assert.AreEqual((byte)0x1, record.Spacing); Assert.AreEqual((short)0x1f, record.Options); Assert.AreEqual(true, record.IsAutoPosition); Assert.AreEqual(true, record.IsAutoSeries); Assert.AreEqual(true, record.IsAutoXPositioning); Assert.AreEqual(true, record.IsAutoYPositioning); Assert.AreEqual(true, record.IsVertical); Assert.AreEqual(false, record.IsDataTable); Assert.AreEqual(24, record.RecordSize); }
public void TestCheckNanPreserve() { byte[] formulaByte = new byte[29]; formulaByte[4] = (byte)0x0F; formulaByte[6] = (byte)0x02; formulaByte[8] = (byte)0x07; formulaByte[12] = (byte)0xFF; formulaByte[13] = (byte)0xFF; formulaByte[18] = (byte)0xE0; formulaByte[19] = (byte)0xFC; formulaByte[20] = (byte)0x07; formulaByte[22] = (byte)0x1E; formulaByte[23] = (byte)0x01; formulaByte[25] = (byte)0x1E; formulaByte[28] = (byte)0x06; FormulaRecord record = new FormulaRecord(TestcaseRecordInputStream.Create(FormulaRecord.sid, formulaByte)); Assert.AreEqual(0, record.Row, "Row"); Assert.AreEqual(0, record.Column, "Column"); Assert.AreEqual(record.CachedResultType, Npoi.Core.SS.UserModel.CellType.Error); byte[] output = record.Serialize(); Assert.AreEqual(33, output.Length, "Output size"); //includes sid+recordlength for (int i = 5; i < 13; i++) { Assert.AreEqual(formulaByte[i], output[i + 4], "FormulaByte NaN doesn't match"); } }
public void TestFillExtras() { byte[] examples = { (byte)0x88, (byte)0x03, (byte)0x67, (byte)0x06, (byte)0x07, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x23, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x4D, (byte)0x61, (byte)0x63, (byte)0x72, (byte)0x6F, (byte)0x31, (byte)0x3A, (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x11, (byte)0x00, (byte)0x00, (byte)0x4D, (byte)0x61, (byte)0x63, (byte)0x72, (byte)0x6F, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x63, (byte)0x6F, (byte)0x72, (byte)0x64, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x32, (byte)0x37, (byte)0x2D, (byte)0x53, (byte)0x65, (byte)0x70, (byte)0x2D, (byte)0x39, (byte)0x33, (byte)0x20, (byte)0x62, (byte)0x79, (byte)0x20, (byte)0x41, (byte)0x4C, (byte)0x4C, (byte)0x57, (byte)0x4F, (byte)0x52 }; NameRecord name = new NameRecord(TestcaseRecordInputStream.Create(NameRecord.sid, examples)); String description = name.DescriptionText; Assert.IsNotNull(description); Assert.IsTrue(description.IndexOf("ALLWOR") > 0, "text contains ALLWOR"); }
public void TestCreateIconCFRule12Record() { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.CreateSheet() as HSSFSheet; CFRule12Record record = CFRule12Record.Create(sheet, IconSet.GREY_5_ARROWS); record.MultiStateFormatting.Thresholds[1].Type = (byte)(RangeType.PERCENT.id); record.MultiStateFormatting.Thresholds[1].Value = (10d); record.MultiStateFormatting.Thresholds[2].Type = (byte)(RangeType.NUMBER.id); record.MultiStateFormatting.Thresholds[2].Value = (-4d); // Check it testCFRule12Record(record); Assert.AreEqual(IconSet.GREY_5_ARROWS, record.MultiStateFormatting.IconSet); Assert.AreEqual(5, record.MultiStateFormatting.Thresholds.Length); // Serialize byte[] serializedRecord = record.Serialize(); // Strip header byte[] recordData = new byte[serializedRecord.Length - 4]; Array.Copy(serializedRecord, 4, recordData, 0, recordData.Length); // Deserialize record = new CFRule12Record(TestcaseRecordInputStream.Create(CFRule12Record.sid, recordData)); // Check it has the icon, and the right number of thresholds Assert.AreEqual(IconSet.GREY_5_ARROWS, record.MultiStateFormatting.IconSet); Assert.AreEqual(5, record.MultiStateFormatting.Thresholds.Length); // Serialize again byte[] output = record.Serialize(); // Compare Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength for (int i = 0; i < recordData.Length; i++) { Assert.AreEqual(recordData[i], output[i + 4], "CFRule12Record doesn't match"); } }
public void TestLoad() { AxisOptionsRecord record = new AxisOptionsRecord(TestcaseRecordInputStream.Create((short)0x1062, data)); Assert.AreEqual(0, record.MinimumCategory); Assert.AreEqual(0, record.MaximumCategory); Assert.AreEqual(1, record.MajorUnitValue); Assert.AreEqual(0, record.MajorUnit); Assert.AreEqual(1, record.MinorUnitValue); Assert.AreEqual(0, record.MinorUnit); Assert.AreEqual(0, record.BaseUnit); Assert.AreEqual(0, record.CrossingPoint); Assert.AreEqual(239, record.Options); Assert.AreEqual(true, record.IsDefaultMinimum); Assert.AreEqual(true, record.IsDefaultMaximum); Assert.AreEqual(true, record.IsDefaultMajor); Assert.AreEqual(true, record.IsDefaultMinorUnit); Assert.AreEqual(false, record.IsDate); Assert.AreEqual(true, record.IsDefaultBase); Assert.AreEqual(true, record.IsDefaultCross); Assert.AreEqual(true, record.IsDefaultDateSettings); Assert.AreEqual(22, record.RecordSize); }
public void TestReadManualComboWithFormula() { byte[] data = HexRead.ReadFromString("" + "5D 00 66 00 " + "15 00 12 00 14 00 02 00 11 20 00 00 00 00 " + "20 44 C6 04 00 00 00 00 0C 00 14 00 04 F0 C6 04 " + "00 00 00 00 00 00 01 00 06 00 00 00 10 00 00 00 " + "0E 00 0C 00 05 00 80 44 C6 04 24 09 00 02 00 02 " + "13 00 DE 1F 10 00 09 00 80 44 C6 04 25 0A 00 0F " + "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 " + "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero ); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ObjRecord or = new ObjRecord(in1); byte[] data2 = or.Serialize(); if (data2.Length == 8228) { throw new AssertionException("Identified bug 45778"); } Assert.AreEqual(data.Length, data2.Length, "Encoded length"); for (int i = 0; i < data.Length; i++) { if (data[i] != data2[i]) { throw new AssertionException("Encoded data differs at index " + i); } } Assert.IsTrue(Arrays.Equals(data, data2)); }
public void TestConstruct() { ObjRecord record = new ObjRecord(); CommonObjectDataSubRecord ftCmo = new CommonObjectDataSubRecord(); ftCmo.ObjectType = (CommonObjectType.COMMENT); ftCmo.ObjectId = ((short)1024); ftCmo.IsLocked = (true); ftCmo.IsPrintable = (true); ftCmo.IsAutoFill = (true); ftCmo.IsAutoline = (true); record.AddSubRecord(ftCmo); EndSubRecord ftEnd = new EndSubRecord(); record.AddSubRecord(ftEnd); //Serialize and Read again byte[] recordBytes = record.Serialize(); //cut off the record header byte[] bytes = new byte[recordBytes.Length - 4]; System.Array.Copy(recordBytes, 4, bytes, 0, bytes.Length); record = new ObjRecord(TestcaseRecordInputStream.Create(ObjRecord.sid, bytes)); IList subrecords = record.GetSubRecords(); Assert.AreEqual(2, subrecords.Count); Assert.IsTrue(subrecords[0] is CommonObjectDataSubRecord); Assert.IsTrue(subrecords[1] is EndSubRecord); }
public void TestAutoStdDocName() { ExternalNameRecord enr; try { enr = CreateSimpleENR(dataAutoDocName); } catch (IndexOutOfRangeException e) { if (e.Message == null) { throw new AssertionException("Identified bug XXXX"); } throw e; } Assert.AreEqual("'191219AW4 Corp,[WORKOUT_PX]'", enr.Text); Assert.IsTrue(enr.IsAutomaticLink); Assert.IsFalse(enr.IsBuiltInName); Assert.IsFalse(enr.IsIconifiedPictureLink); Assert.IsFalse(enr.IsOLELink); Assert.IsFalse(enr.IsPicureLink); Assert.IsTrue(enr.IsStdDocumentNameIdentifier); TestcaseRecordInputStream.ConfirmRecordEncoding(0x0023, dataAutoDocName, enr.Serialize()); }
public void TestUnicodeName_bug47384() { // data taken from bugzilla 47384 att 23830 at offset 0x13A0 byte[] dataUN = NPOI.Util.HexRead.ReadFromString( "23 00 22 00" + "00 00 00 00 00 00 " + "0C 01 " + "59 01 61 00 7A 00 65 00 6E 00 ED 00 5F 00 42 00 69 00 6C 00 6C 00 61 00" + "00 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(dataUN); ExternalNameRecord enr; try { enr = new ExternalNameRecord(in1); } catch (RecordFormatException e) { if (e.Message.StartsWith("Expected to find a ContinueRecord in order to read remaining 242 of 268 chars")) { throw new AssertionException("Identified bug 47384 - failed to read ENR with unicode name"); } throw e; } Assert.AreEqual("\u0159azen\u00ED_Billa", enr.Text); }
public void TestStore() { // .fontheight = c8 // .attributes = 0 // .italic = false // .strikout = false // .macoutlined= false // .macshadowed= false // .colorpalette = 7fff // .boldweight = 190 // .supersubscript = 0 // .underline = 0 // .family = 0 // .charset = 0 // .namelength = 5 // .fontname = Arial FontRecord record = new FontRecord(); record.FontHeight = ((short)0xc8); record.Attributes = ((short)0); record.ColorPaletteIndex = ((short)0x7fff); record.BoldWeight = ((short)0x190); record.SuperSubScript = ((short)0); record.Underline = ((byte)0); record.Family = ((byte)0); record.Charset = ((byte)0); record.FontName = ("Arial"); byte[] recordBytes = record.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(0x31, data, recordBytes); }
public void TestChangeOfCompressionFlag_bug25866() { byte[] changingFlagSimpleData = HexRead.ReadFromString("" + "AA AA " // fake SID + "06 00 " // first rec len 6 + HED_DUMP1 ); RecordInputStream in1 = TestcaseRecordInputStream.Create(changingFlagSimpleData); String actual; try { actual = in1.ReadUnicodeLEString(18); } catch (ArgumentException e) { if ("compressByte in continue records must be 1 while Reading unicode LE string".Equals(e.Message)) { throw new AssertionException("Identified bug 45866"); } throw e; } Assert.AreEqual("\u591A\u8A00\u8A9E - Multilingual", actual); }
public void Test_47701() { byte[] data = HexRead.ReadFromString( "15, 00, 12, 00, 12, 00, 02, 00, 11, 20, " + "00, 00, 00, 00, 80, 3D, 03, 05, 00, 00, " + "00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " + "00, 00, 00, 00, 00, 00, 01, 00, 0A, 00, " + "00, 00, 10, 00, 01, 00, 13, 00, EE, 1F, " + "10, 00, 09, 00, 40, 9F, 74, 01, 25, 09, " + "00, 0C, 00, 07, 00, 07, 00, 07, 04, 00, " + "00, 00, 08, 00, 00, 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data); // check read OK ObjRecord record = new ObjRecord(in1); Assert.AreEqual(3, record.SubRecords.Count); SubRecord sr = record.SubRecords[(2)]; Assert.IsTrue(sr is LbsDataSubRecord); LbsDataSubRecord lbs = (LbsDataSubRecord)sr; Assert.AreEqual(4, lbs.NumberOfItems); Assert.IsTrue(lbs.Formula is AreaPtg); AreaPtg ptg = (AreaPtg)lbs.Formula; CellRangeAddress range = new CellRangeAddress( ptg.FirstRow, ptg.LastRow, ptg.FirstColumn, ptg.LastColumn); Assert.AreEqual("H10:H13", range.FormatAsString()); // check that it re-Serializes to the same data byte[] ser = record.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser); }
public void TestRead() { String hex = "21 02 25 00 01 00 01 00 01 01 00 00 00 00 00 00 " + "17 00 65 00 00 01 00 02 C0 02 C0 65 00 00 01 00 " + "03 C0 03 C0 04 62 01 07 00"; byte[] data = HexRead.ReadFromString(hex); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ArrayRecord r1 = new ArrayRecord(in1); CellRangeAddress8Bit range = r1.Range; Assert.AreEqual(1, range.FirstColumn); Assert.AreEqual(1, range.LastColumn); Assert.AreEqual(1, range.FirstRow); Assert.AreEqual(1, range.LastRow); Ptg[] ptg = r1.FormulaTokens; Assert.AreEqual(FormulaRenderer.ToFormulaString(null, ptg), "MAX(C1:C2-D1:D2)"); //construct a new ArrayRecord with the same contents as r1 Ptg[] fmlaPtg = FormulaParser.Parse("MAX(C1:C2-D1:D2)", null, FormulaType.Array, 0); ArrayRecord r2 = new ArrayRecord(Formula.Create(fmlaPtg), new CellRangeAddress8Bit(1, 1, 1, 1)); byte[] ser = r2.Serialize(); //serialize and check that the data is the same as in r1 Assert.AreEqual(HexDump.ToHex(data), HexDump.ToHex(ser)); }
public void TestRead() { NoteStructureSubRecord record = new NoteStructureSubRecord(TestcaseRecordInputStream.Create(NoteStructureSubRecord.sid, data), data.Length); Assert.AreEqual(NoteStructureSubRecord.sid, record.Sid); Assert.AreEqual(data.Length, record.DataSize); }
public void TestshortRecordWrittenByMSAccess() { /* * Data taken from two example files * ex42564-21435.xls * bug_42794.xls (from bug 42794 attachment 20429) * In both cases, this data is found at offset 0x0C1C. */ byte[] data = HexRead.ReadFromString("" + "5C 00 39 00 " + "36 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D " + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 " + "20 55 73 65 72" + "20 20 20 20 20 20 20 20 20 20 20 " + "20 20 20 20 20 20 20 20 20"); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); WriteAccessRecord rec = new WriteAccessRecord(in1); Assert.AreEqual("A satisfied Microsoft Office9 User", rec.Username); byte[] expectedEncoding = HexRead.ReadFromString("" + "22 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D " + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 " + "20 55 73 65 72" + "20 20 20 20 20 20 20 20 20 20 20 " + HEX_SIXTYFOUR_SPACES); TestcaseRecordInputStream.ConfirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.Serialize()); }
public void TestCreateCFRuleRecord() { HSSFWorkbook workbook = new HSSFWorkbook(); CFRuleRecord record = CFRuleRecord.Create(workbook, "7"); TestCFRuleRecord1(record); // Serialize byte[] SerializedRecord = record.Serialize(); // Strip header byte[] recordData = new byte[SerializedRecord.Length - 4]; Array.Copy(SerializedRecord, 4, recordData, 0, recordData.Length); // DeSerialize record = new CFRuleRecord(TestcaseRecordInputStream.Create(CFRuleRecord.sid, recordData)); // Serialize again byte[] output = record.Serialize(); // Compare Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength for (int i = 0; i < recordData.Length; i++) { Assert.AreEqual(recordData[i], output[i + 4], "CFRuleRecord doesn't match"); } }
public void TestRead() { FtCblsSubRecord record = new FtCblsSubRecord(TestcaseRecordInputStream.Create(FtCblsSubRecord.sid, data), data.Length); Assert.AreEqual(FtCblsSubRecord.sid, record.Sid); Assert.AreEqual(data.Length, record.DataSize); }
public void TestBadFirstField_bug48096() { /** * Data taken from the sample file referenced in Bugzilla 48096, file offset 0x0D45. * The apparent problem is that the first data short field has been written with the * wrong <i>endianness</n>. Excel seems to ignore whatever value is present in this * field, and always reWrites it as (C1, 01). POI now does the same. */ byte[] badData = HexRead.ReadFromString("C1 01 08 00 01 C1 00 00 00 01 69 61"); byte[] goodData = HexRead.ReadFromString("C1 01 08 00 C1 01 00 00 00 01 69 61"); RecordInputStream in1 = TestcaseRecordInputStream.Create(badData); RecalcIdRecord r; try { r = new RecalcIdRecord(in1); } catch (RecordFormatException e) { if (e.Message.Equals("expected 449 but got 49409")) { throw new AssertionException("Identified bug 48096"); } throw e; } Assert.AreEqual(0, in1.Remaining); Assert.IsTrue(Arrays.Equals(r.Serialize(), goodData)); }
public void TestGetPath() { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.Create(81, data1)); byte[] expResult = Arrays.CopyOfRange(data1, 9, data1.Length); byte[] result = instance.GetPath(); Assert.IsTrue(Arrays.Equals(expResult, result), "get path"); }
public void TestReserializeTargetFrame() { RecordInputStream in1 = TestcaseRecordInputStream.Create(HyperlinkRecord.sid, dataTargetFrame); HyperlinkRecord hr = new HyperlinkRecord(in1); byte[] ser = hr.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(HyperlinkRecord.sid, dataTargetFrame, ser); }
private static RecalcIdRecord Create(byte[] data) { RecordInputStream in1 = TestcaseRecordInputStream.Create(RecalcIdRecord.sid, data); RecalcIdRecord result = new RecalcIdRecord(in1); Assert.AreEqual(0, in1.Remaining); return(result); }
public void TestLoad() { PlotAreaRecord record = new PlotAreaRecord(TestcaseRecordInputStream.Create(0x1035, data)); Assert.AreEqual(4, record.RecordSize); }
public void TestLoad() { StringRecord record = new StringRecord(TestcaseRecordInputStream.Create(0x207, data)); Assert.AreEqual("Fahrzeugtyp", record.String); Assert.AreEqual(18, record.RecordSize); }
public void TestIsExternalRef() { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.Create(81, data1)); Assert.IsTrue(instance.IsExternalRef, "external reference"); instance = new DConRefRecord(TestcaseRecordInputStream.Create(81, data2)); Assert.IsFalse(instance.IsExternalRef, "internal reference"); }
public void TestLoadAIF() { SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.Create(0x01AE, dataAIF)); Assert.IsTrue(record.IsAddInFunctions); //expected flag Assert.AreEqual(0x1, record.NumberOfSheets); //expected # of sheets Assert.AreEqual(8, record.RecordSize); //sid+size+data }
public void TestGetSid() { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.Create(81, data1)); short expResult = 81; short result = instance.Sid; Assert.AreEqual(expResult, result, "SID"); }
public void TestStoreER() { string url = "testURL"; string[] sheetNames = { "Sheet1", "Sheet2", }; SupBookRecord record = SupBookRecord.CreateExternalReferences(url, sheetNames); TestcaseRecordInputStream.ConfirmRecordEncoding(0x01AE, dataER, record.Serialize()); }
public void TestLoadIR() { SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.Create(0x01AE, dataIR)); Assert.IsTrue(record.IsInternalReferences); //expected flag Assert.AreEqual(0x4, record.NumberOfSheets); //expected # of sheets Assert.AreEqual(8, record.RecordSize); //sid+size+data }
private static void ConfirmRead(byte[] data, int i) { RecordInputStream in1 = TestcaseRecordInputStream.Create(EORSR_SID, data); EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in1, data.Length); byte[] ser2 = rec.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding("Test record " + i, EORSR_SID, data, ser2); }