aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2008-08-25 18:57:14 +0000
committerJosh Micich <josh@apache.org>2008-08-25 18:57:14 +0000
commitd4b6c06f2b15a1aa1e9f991192e6869ca35d4f3a (patch)
tree01620cfbc5c34db931f1123c7f474d9c8a5f9f86 /src/testcases/org/apache/poi/hssf
parent4b73edb1915bc89c43dd2f12f3d152f897fad195 (diff)
downloadpoi-d4b6c06f2b15a1aa1e9f991192e6869ca35d4f3a.tar.gz
poi-d4b6c06f2b15a1aa1e9f991192e6869ca35d4f3a.zip
Fix for small bug introduced in c688655 - keep header field in sync with number of rules
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@688825 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r--src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java
index 2b2971453d..aac6ba0315 100644
--- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java
+++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestCFRecordsAggregate.java
@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.hssf.model.RecordStream;
@@ -31,6 +32,7 @@ import org.apache.poi.hssf.record.RecordFactory;
import org.apache.poi.hssf.record.CFRuleRecord.ComparisonOperator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
+import org.apache.poi.util.LittleEndian;
/**
* Tests the serialization and deserialization of the CFRecordsAggregate
@@ -99,4 +101,28 @@ public final class TestCFRecordsAggregate extends TestCase
assertEquals(2, cellRanges.length);
assertEquals(3, header.getNumberOfConditionalFormats());
}
+
+ /**
+ * Make sure that the CF Header record is properly updated with the number of rules
+ */
+ public void testNRules() {
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ CellRangeAddress[] cellRanges = {
+ new CellRangeAddress(0,1,0,0),
+ new CellRangeAddress(0,1,2,2),
+ };
+ CFRuleRecord[] rules = {
+ CFRuleRecord.create(workbook, "7"),
+ CFRuleRecord.create(workbook, ComparisonOperator.BETWEEN, "2", "5"),
+ };
+ CFRecordsAggregate agg = new CFRecordsAggregate(cellRanges, rules);
+ byte[] serializedRecord = new byte[agg.getRecordSize()];
+ agg.serialize(0, serializedRecord);
+
+ int nRules = LittleEndian.getUShort(serializedRecord, 4);
+ if (nRules == 0) {
+ throw new AssertionFailedError("Identified bug 45682 b");
+ }
+ assertEquals(rules.length, nRules);
+ }
}