]> source.dussan.org Git - poi.git/commitdiff
Added junits for existing functionality of ColumnInfoRecord
authorJosh Micich <josh@apache.org>
Wed, 2 Dec 2009 20:56:59 +0000 (20:56 +0000)
committerJosh Micich <josh@apache.org>
Wed, 2 Dec 2009 20:56:59 +0000 (20:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886299 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/record/AllRecordTests.java
src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java [new file with mode: 0644]

index adb249ef34e99471078bc0596bbe8a239bec840a..d20940989f30653e13fae0d24a9e85d04f7e8743 100644 (file)
@@ -50,6 +50,7 @@ public final class AllRecordTests {
                result.addTestSuite(TestCellRange.class);
                result.addTestSuite(TestCFHeaderRecord.class);
                result.addTestSuite(TestCFRuleRecord.class);
+               result.addTestSuite(TestColumnInfoRecord.class);
                result.addTestSuite(TestCommonObjectDataSubRecord.class);
                result.addTestSuite(TestConstantValueParser.class);
                result.addTestSuite(TestDrawingGroupRecord.class);
diff --git a/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java
new file mode 100644 (file)
index 0000000..8f11d90
--- /dev/null
@@ -0,0 +1,64 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record;
+
+import java.util.Arrays;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.apache.poi.util.HexRead;
+
+/**
+ * Tests for {@link ColumnInfoRecord}
+ *
+ * @author Josh Micich
+ */
+public final class TestColumnInfoRecord extends TestCase {
+
+       public void testBasic() {
+               byte[] data = HexRead.readFromString("7D 00 0C 00 14 00 9B 00 C7 19 0F 00 01 13 00 00");
+
+               RecordInputStream in = TestcaseRecordInputStream.create(data);
+               ColumnInfoRecord cir = new ColumnInfoRecord(in);
+               assertEquals(0, in.remaining());
+
+               assertEquals(20, cir.getFirstColumn());
+               assertEquals(155, cir.getLastColumn());
+               assertEquals(6599, cir.getColumnWidth());
+               assertEquals(15, cir.getXFIndex());
+               assertEquals(true, cir.getHidden());
+               assertEquals(3, cir.getOutlineLevel());
+               assertEquals(true, cir.getCollapsed());
+               assertTrue(Arrays.equals(data, cir.serialize()));
+       }
+
+       /**
+        * Some sample files have just one reserved byte (field 6):
+        * OddStyleRecord.xls, NoGutsRecords.xls, WORKBOOK_in_capitals.xls
+        * but this seems to cause no problem to Excel
+        */
+       public void testOneReservedByte() {
+               byte[] inpData = HexRead.readFromString("7D 00 0B 00 00 00 00 00 24 02 0F 00 00 00 01");
+               byte[] outData = HexRead.readFromString("7D 00 0C 00 00 00 00 00 24 02 0F 00 00 00 01 00");
+               RecordInputStream in = TestcaseRecordInputStream.create(inpData);
+               ColumnInfoRecord cir = new ColumnInfoRecord(in);
+               assertEquals(0, in.remaining());
+               assertTrue(Arrays.equals(outData, cir.serialize()));
+       }
+}