aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2008-10-31 18:37:16 +0000
committerJosh Micich <josh@apache.org>2008-10-31 18:37:16 +0000
commit75e352f2a073bdda52a2e3c30df63be6c71ff61d (patch)
tree2a23b0650c1d81060f73d320ddbb5ffc217da5d2 /src/testcases
parent0f60f5eba5bfff80c34df7db0a42d9a457dbbc35 (diff)
downloadpoi-75e352f2a073bdda52a2e3c30df63be6c71ff61d.tar.gz
poi-75e352f2a073bdda52a2e3c30df63be6c71ff61d.zip
Merged revisions 709263-709264,709317 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r709263 | josh | 2008-10-30 15:07:26 -0700 (Thu, 30 Oct 2008) | 1 line Removed dodgy superlcass implementation of Record.getRecordSize() ........ r709264 | josh | 2008-10-30 15:13:56 -0700 (Thu, 30 Oct 2008) | 1 line Introduced Record.getDataSize() method ........ r709317 | josh | 2008-10-30 18:02:55 -0700 (Thu, 30 Oct 2008) | 1 line converted getRecordSize methods to getDataSize ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@709526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/util/TestRKUtil.java48
2 files changed, 29 insertions, 24 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index 4357c57e3b..4b4dd0af7a 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -30,7 +30,6 @@ import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordFormatException;
-import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.TempFile;
@@ -504,8 +503,8 @@ public final class TestHSSFWorkbook extends TestCase {
public int serialize(int offset, byte[] data) {
return 4;
}
- public int getRecordSize() {
- return 8;
+ protected int getDataSize() {
+ return 4;
}
}
diff --git a/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java b/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java
index e158aafc5f..5b845775fe 100644
--- a/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java
+++ b/src/testcases/org/apache/poi/hssf/util/TestRKUtil.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,31 +14,38 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.util;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
/**
- * Tests the RKUtil class.
+ * Tests the {@link RKUtil} class.
*/
-public class TestRKUtil
- extends TestCase
-{
- public TestRKUtil(String s)
- {
- super(s);
- }
-
- /**
- * Check we can decode correctly.
- */
- public void testDecode()
- throws Exception
- {
- assertEquals(3.0, RKUtil.decodeNumber(1074266112), 0.0000001);
- assertEquals(3.3, RKUtil.decodeNumber(1081384961), 0.0000001);
- assertEquals(3.33, RKUtil.decodeNumber(1081397249), 0.0000001);
- }
+public final class TestRKUtil extends TestCase {
+
+ /**
+ * Check we can decode correctly.
+ */
+ public void testDecode() {
+
+ int[] values = { 1074266112, 1081384961, 1081397249,
+ 0x3FF00000, 0x405EC001, 0x02F1853A, 0x02F1853B, 0xFCDD699A,
+ };
+ double[] rvalues = { 3.0, 3.3, 3.33,
+ 1, 1.23, 12345678, 123456.78, -13149594,
+ };
+
+ for (int j = 0; j < values.length; j++) {
+
+ int intBits = values[j];
+ double expectedValue = rvalues[j];
+ double actualValue = RKUtil.decodeNumber(intBits);
+ if (expectedValue != actualValue) {
+ throw new AssertionFailedError("0x" + Integer.toHexString(intBits)
+ + " should decode to " + expectedValue + " but got " + actualValue);
+ }
+ }
+ }
}