Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions openxml4Net/OPC/Internal/ZipHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ public static void VerifyZipHeader(InputStream stream)
{
stream.Reset();
}
else if (stream is FileStream)
{
// File open check, about to be closed, nothing to do
}
else
{
// Oh dear... I hope you know what you're doing!
Expand Down
16 changes: 8 additions & 8 deletions test.runsettings
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory>
<ResultsDirectory>./TestResults</ResultsDirectory>
</RunConfiguration>

<TestRunParameters>
<Parameter name="loggername" value="TestCases.Util.DummyPOILogger,NPOI.TestCases"/>
<Parameter name="HSSF.testdata.path" value="..\..\..\testcases\test-data\hssf"/>
<Parameter name="POIFS.testdata.path" value="..\..\..\testcases\test-data\poifs"/>
<Parameter name="POI.testdata.path" value="..\..\..\testcases\test-data"/>
<Parameter name="java.io.tmpdir" value="..\..\..\testcases\test-data"/>
<Parameter name="poi.keep.tmp.files" value="..\..\..\testcases\test-data\"/>
<Parameter name="font.metrics.filename" value="..\..\..\testcases\test-data\font_metrics.properties"/>
<Parameter name="escher.data.path" value="..\..\..\testcases\test-data\ddf\"/>
<Parameter name="HSSF.testdata.path" value="../../../testcases/test-data/hssf"/>
<Parameter name="POIFS.testdata.path" value="../../../testcases/test-data/poifs"/>
<Parameter name="POI.testdata.path" value="../../../testcases/test-data"/>
<Parameter name="java.io.tmpdir" value="../../../testcases/test-data"/>
<Parameter name="poi.keep.tmp.files" value="../../../testcases/test-data/"/>
<Parameter name="font.metrics.filename" value="../../../testcases/test-data/font_metrics.properties"/>
<Parameter name="escher.data.path" value="../../../testcases/test-data/ddf/"/>
</TestRunParameters>
</RunSettings>
30 changes: 15 additions & 15 deletions testcases/main/HSSF/Model/TestFormulaParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,14 @@ public void TestMissingArgs()

Type[] expClss;

expClss = new Type[] {
typeof(RefPtg),
expClss = new Type[] {
typeof(RefPtg),
typeof(AttrPtg), // tAttrIf
typeof(MissingArgPtg),
typeof(MissingArgPtg),
typeof(AttrPtg), // tAttrSkip
typeof(RefPtg),
typeof(AttrPtg), // tAttrSkip
typeof(FuncVarPtg),
typeof(FuncVarPtg),
};

ConfirmTokenClasses("if(A1, ,C1)", expClss);
Expand Down Expand Up @@ -868,7 +868,7 @@ public void TestParseStringLiterals_bug28754()
{
Assert.Fail("Identified bug 28754a");
}
throw e;
throw;
}
Assert.AreEqual("test\"ing", sp.Value);

Expand Down Expand Up @@ -1240,16 +1240,16 @@ public void TestParseArray()

ArrayPtg aptg = (ArrayPtg)ptgs[0];
Object[,] values = aptg.GetTokenArrayValues();
Assert.AreEqual(ErrorConstant.ValueOf(FormulaError.REF.Code), values[0,3]);
Assert.AreEqual(false, values[1,0]);
Assert.AreEqual(ErrorConstant.ValueOf(FormulaError.REF.Code), values[0, 3]);
Assert.AreEqual(false, values[1, 0]);
}
[Test]
public void TestParseStringElementInArray()
{
Ptg[] ptgs;
ptgs = ParseFormula("MAX({\"5\"},3)");
ConfirmTokenClasses(ptgs, typeof(ArrayPtg), typeof(IntPtg), typeof(FuncVarPtg));
object element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0,0];
object element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0, 0];
if (element is UnicodeString)
{
// this would cause ClassCastException below
Expand Down Expand Up @@ -1290,14 +1290,14 @@ public void TestParseArrayNegativeElement()
throw e;
}
ConfirmTokenClasses(ptgs, typeof(ArrayPtg));
Object element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0,0];
Object element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0, 0];

Assert.AreEqual(-42.0, (Double)element, 0.0);

// Should be able to handle whitespace between unary minus and digits (Excel
// accepts this formula after presenting the user with a Confirmation dialog).
ptgs = ParseFormula("{- 5}");
element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0,0];
element = ((ArrayPtg)ptgs[0]).GetTokenArrayValues()[0, 0];
Assert.AreEqual(-5.0, (Double)element, 0.0);
}
[Test]
Expand Down Expand Up @@ -1378,7 +1378,7 @@ public void TestUnion()
Ptg[] ptgs = FormulaParser.Parse(formula, HSSFEvaluationWorkbook.Create(wb), FormulaType.Cell, -1, -1);

ConfirmTokenClasses(ptgs,
// TODO - AttrPtg), // Excel prepends this
// TODO - AttrPtg), // Excel prepends this
typeof(MemFuncPtg),
typeof(Area3DPtg),
typeof(Area3DPtg),
Expand Down Expand Up @@ -1406,7 +1406,7 @@ public void TestIntersection()
wb.CreateSheet("Sheet1");
Ptg[] ptgs = FormulaParser.Parse(formula, HSSFEvaluationWorkbook.Create(wb), FormulaType.Cell, -1);
ConfirmTokenClasses(ptgs,
// TODO - AttrPtg.class, // Excel prepends this
// TODO - AttrPtg.class, // Excel prepends this
typeof(MemFuncPtg),
typeof(Area3DPtg),
typeof(Area3DPtg),
Expand Down Expand Up @@ -1456,7 +1456,7 @@ public void TestIntersectionInParen()
typeof(ParenthesisPtg)
);
}


/** Named ranges with backslashes, e.g. 'POI\\2009' */
[Test]
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public void TestRangeFuncOperand_bug46951()
Assert.Fail("Identified bug 46951");
}
wb.Close();
throw e;
throw;
}
ConfirmTokenClasses(ptgs,
typeof(MemFuncPtg), // [len=23]
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public void TestComplexExplicitRangeEncodings()

ptgs = ParseFormula("SUM(A1:B2:C3:D4)");
ConfirmTokenClasses(ptgs,
// AttrPtg), // [volatile ] // POI doesn't do this yet (Apr 2009)
// AttrPtg), // [volatile ] // POI doesn't do this yet (Apr 2009)
typeof(MemAreaPtg), // len 19
typeof(AreaPtg), // [A1:B2]
typeof(AreaPtg), // [C3:D4]
Expand Down
6 changes: 3 additions & 3 deletions testcases/main/HSSF/Model/TestLinkTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void TestLinkTableWithoutExternalBookRecord_bug45046()
{
throw new AssertionException("Identified bug 45046 b");
}
throw e;
throw;
}
// some other sanity Checks
Assert.AreEqual(3, wb.NumberOfSheets);
Expand Down Expand Up @@ -90,7 +90,7 @@ public void TestMultipleExternSheetRecords_bug45698()
{
throw new AssertionException("Identified bug 45698");
}
throw e;
throw;
}
// some other sanity Checks
Assert.AreEqual(7, wb.NumberOfSheets);
Expand Down Expand Up @@ -169,7 +169,7 @@ public void TestMissingExternSheetRecord_bug47001b()
throw new AssertionException("Identified bug 47001b");
}

throw e;
throw;
}
Assert.IsNotNull(lt);
}
Expand Down
100 changes: 58 additions & 42 deletions testcases/main/HSSF/Model/TestSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ public void TestCreateSheet()
Assert.IsTrue(outRecs[pos++] is EOFRecord);
}

private class MergedCellListener:RecordVisitor
{
private class MergedCellListener : RecordVisitor
{

private int _count;
public MergedCellListener() {
public MergedCellListener()
{
_count = 0;
}
public void VisitRecord(Record r) {
if (r is MergeCellsRecord) {
public void VisitRecord(Record r)
{
if (r is MergeCellsRecord)
{
_count++;
}
}
Expand Down Expand Up @@ -115,7 +118,7 @@ public void TestAddMergedRegion()
//test that the regions were spread out over the appropriate number of records
MergedCellListener mcListener = new MergedCellListener();
sheet.VisitContainedRecords(mcListener, 0);
int recordsAdded = mcListener.Count;
int recordsAdded = mcListener.Count;
int recordsExpected = regionsToAdd / 1027;
if ((regionsToAdd % 1027) != 0)
recordsExpected++;
Expand Down Expand Up @@ -149,7 +152,7 @@ public void TestRemoveMergedRegion()
int regionsToAdd = 4096;

for (int n = 0; n < regionsToAdd; n++)
sheet.AddMergedRegion(0, 0, 1,1);
sheet.AddMergedRegion(0, 0, 1, 1);

int nSheetRecords = sheet.Records.Count;

Expand All @@ -158,7 +161,7 @@ public void TestRemoveMergedRegion()
{
sheet.RemoveMergedRegion(0);
//assert they have been deleted
Assert.AreEqual(sheet.NumMergedRegions,regionsToAdd - n - 1, "Num of regions should be " + (regionsToAdd - n - 1) + " not " + sheet.NumMergedRegions);
Assert.AreEqual(sheet.NumMergedRegions, regionsToAdd - n - 1, "Num of regions should be " + (regionsToAdd - n - 1) + " not " + sheet.NumMergedRegions);
}

// merge records are removed from within the MergedCellsTable,
Expand Down Expand Up @@ -211,12 +214,12 @@ public void TestGetNumMergedRegions()
private static Record CreateWindow2Record()
{
WindowTwoRecord result = new WindowTwoRecord();
result.Options=((short)0x6b6);
result.TopRow=((short)0);
result.LeftCol=((short)0);
result.HeaderColor=(0x40);
result.PageBreakZoom=((short)0);
result.NormalZoom=((short)0);
result.Options = ((short)0x6b6);
result.TopRow = ((short)0);
result.LeftCol = ((short)0);
result.HeaderColor = (0x40);
result.PageBreakZoom = ((short)0);
result.NormalZoom = ((short)0);
return result;
}

Expand Down Expand Up @@ -284,10 +287,14 @@ public void TestRowPageBreaks()
for (int i = 0; i < rowBreaks.Length; i++)
{
int main = rowBreaks[i];
if (main != 0 && main != 10 && main != 11) Assert.Fail("Invalid page break");
if (main == 0) is0 = true;
if (main == 10) is10 = true;
if (main == 11) is11 = true;
if (main != 0 && main != 10 && main != 11)
Assert.Fail("Invalid page break");
if (main == 0)
is0 = true;
if (main == 10)
is10 = true;
if (main == 11)
is11 = true;
}

Assert.IsTrue(is0 && is10 && is11, "one of the breaks didnt make it");
Expand Down Expand Up @@ -344,11 +351,16 @@ public void TestColPageBreaks()
for (int i = 0; i < colBreaks.Length; i++)
{
int main = colBreaks[i];
if (main != 0 && main != 1 && main != 10 && main != 15) Assert.Fail("Invalid page break");
if (main == 0) is0 = true;
if (main == 1) is1 = true;
if (main == 10) is10 = true;
if (main == 15) is15 = true;
if (main != 0 && main != 1 && main != 10 && main != 15)
Assert.Fail("Invalid page break");
if (main == 0)
is0 = true;
if (main == 1)
is1 = true;
if (main == 10)
is10 = true;
if (main == 15)
is15 = true;
}

Assert.IsTrue(is0 && is1 && is10 && is15, "one of the breaks didnt make it");
Expand Down Expand Up @@ -568,31 +580,35 @@ public void VisitRecord(Record r)
* Checks for bug introduced around r682282-r683880 that caused a second GUTS records
* which in turn got the dimensions record out of alignment
*/
public void TestGutsRecord_bug45640() {
public void TestGutsRecord_bug45640()
{

InternalSheet sheet = InternalSheet.CreateSheet();
sheet.AddRow(new RowRecord(0));
sheet.AddRow(new RowRecord(1));
sheet.GroupRowRange( 0, 1, true );
sheet.ToString();
IList recs = sheet.Records;
int count=0;
for(int i=0; i< recs.Count; i++) {
if (recs[i] is GutsRecord) {
count++;
sheet.AddRow(new RowRecord(0));
sheet.AddRow(new RowRecord(1));
sheet.GroupRowRange(0, 1, true);
sheet.ToString();
IList recs = sheet.Records;
int count = 0;
for (int i = 0; i < recs.Count; i++)
{
if (recs[i] is GutsRecord)
{
count++;
}
}
if (count == 2)
{
throw new AssertionException("Identified bug 45640");
}
Assert.AreEqual(1, count);
}
if (count == 2) {
throw new AssertionException("Identified bug 45640");
}
Assert.AreEqual(1, count);
}

public void TestMisplacedMergedCellsRecords_bug45699()
{
HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("ex45698-22488.xls");

HSSFSheet sheet =(HSSFSheet)wb.GetSheetAt(0);
HSSFSheet sheet = (HSSFSheet)wb.GetSheetAt(0);
HSSFRow row = (HSSFRow)sheet.GetRow(3);
HSSFCell cell = (HSSFCell)row.GetCell(4);
if (cell == null)
Expand Down Expand Up @@ -658,7 +674,7 @@ public void TestMissingDims()
{
throw new AssertionException("Identified bug 46206");
}
throw e;
throw;
}

RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector();
Expand Down Expand Up @@ -689,7 +705,7 @@ public void TestShiftFormulasAddCondFormat_bug46547()
//Assert.AreEqual(23, sheetRecs.Count);
Assert.AreEqual(24, sheetRecs.Count); //for SheetExtRecord

FormulaShifter shifter = FormulaShifter.CreateForRowShift(0,"", 0, 0, 1, SpreadsheetVersion.EXCEL97);
FormulaShifter shifter = FormulaShifter.CreateForRowShift(0, "", 0, 0, 1, SpreadsheetVersion.EXCEL97);
sheet.UpdateFormulasAfterCellShift(shifter, 0);
if (sheetRecs.Count == 25 && sheetRecs[22] is ConditionalFormattingTable)
{
Expand Down Expand Up @@ -748,7 +764,7 @@ public void TestCloneMulBlank_bug46776()
{
throw new AssertionException("Identified bug 46776");
}
throw e;
throw;
}

TestCases.HSSF.UserModel.RecordInspector.RecordCollector rc = new TestCases.HSSF.UserModel.RecordInspector.RecordCollector();
Expand Down
Loading