diff options
author | Josh Micich <josh@apache.org> | 2008-10-31 18:37:16 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2008-10-31 18:37:16 +0000 |
commit | 75e352f2a073bdda52a2e3c30df63be6c71ff61d (patch) | |
tree | 2a23b0650c1d81060f73d320ddbb5ffc217da5d2 /src/testcases/org/apache/poi/hssf/util | |
parent | 0f60f5eba5bfff80c34df7db0a42d9a457dbbc35 (diff) | |
download | poi-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/org/apache/poi/hssf/util')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/util/TestRKUtil.java | 48 |
1 files changed, 27 insertions, 21 deletions
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); + } + } + } } |