From 3977d9063121ae5f5ae27e16e691a39685451da4 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Wed, 2 Dec 2009 20:56:59 +0000 Subject: [PATCH] Added junits for existing functionality of ColumnInfoRecord git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886299 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/record/AllRecordTests.java | 1 + .../poi/hssf/record/TestColumnInfoRecord.java | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java diff --git a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java index adb249ef34..d20940989f 100644 --- a/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java +++ b/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java @@ -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 index 0000000000..8f11d90604 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java @@ -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())); + } +} -- 2.39.5