|
From: <mar...@us...> - 2010-07-26 17:19:44
|
Revision: 3293
http://bigdata.svn.sourceforge.net/bigdata/?rev=3293&view=rev
Author: martyncutcher
Date: 2010-07-26 17:19:38 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
Add further zero oriented tests and comment out invalid test data from bigDecimal0
Modified Paths:
--------------
branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java
Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java
===================================================================
--- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-26 17:17:51 UTC (rev 3292)
+++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-26 17:19:38 UTC (rev 3293)
@@ -1634,7 +1634,7 @@
}
- if (cause != null || !expected.equals(actual)) {
+ if (cause != null || !(expected.compareTo(actual) == 0)) {
final String msg = "BigDecimal" + //
"\nexpected=" + expected + //
@@ -1690,6 +1690,32 @@
}
+ protected void doEQTest(final BigDecimal i1, final BigDecimal i2) {
+
+ final byte[] k1 = encodeBigDecimal(i1);
+
+ final byte[] k2 = encodeBigDecimal(i2);
+
+ final int ret = BytesUtil.compareBytes(k1, k2);
+
+ if (ret != 0) {
+
+ fail("BigDecimal" + //
+ "\ni1=" + i1 + //
+ "\ni2=" + i2 + //
+// "\ns1=" + Arrays.toString(i1.toByteArray())+//
+// "\ns2=" + Arrays.toString(i2.toByteArray())+//
+// "\nu1=" + BytesUtil.toString(i1.toByteArray())+//
+// "\nu2=" + BytesUtil.toString(i2.toByteArray())+//
+ "\nk1=" + BytesUtil.toString(k1) + //
+ "\nk2=" + BytesUtil.toString(k2) + //
+ "\nret=" + (ret == 0 ? "EQ" : (ret < 0 ? "LT" : "GT"))//
+ );
+
+ }
+
+ }
+
protected void doLTTest(final BigDecimal i1, final BigDecimal i2) {
final byte[] k1 = encodeBigDecimal(i1);
@@ -1748,6 +1774,43 @@
}
+ public void test_BigDecimal_zeros() {
+
+ final BigDecimal z1 = new BigDecimal("0.0");
+ final BigDecimal negz1 = new BigDecimal("-0.0");
+ final BigDecimal z2 = new BigDecimal("0.00");
+ final BigDecimal p1 = new BigDecimal("0.01");
+ final BigDecimal negp1 = new BigDecimal("-0.01");
+ final BigDecimal z3 = new BigDecimal("0000.00");
+ final BigDecimal m1 = new BigDecimal("1.5");
+ final BigDecimal m2 = new BigDecimal("-1.51");
+ final BigDecimal m5 = new BigDecimal("5");
+ final BigDecimal m53 = new BigDecimal("5.000");
+ final BigDecimal m500 = new BigDecimal("00500");
+ final BigDecimal m5003 = new BigDecimal("500.000");
+
+ doLTTest(z1, p1);
+ doLTTest(negp1, z1);
+ doLTTest(negp1, p1);
+ doEQTest(z1, negz1);
+
+ doEncodeDecodeTest(m5);
+ doEncodeDecodeTest(z1);
+ doEncodeDecodeTest(z2);
+ doEncodeDecodeTest(z3);
+ doEncodeDecodeTest(m1);
+ doEncodeDecodeTest(m2);
+
+ doEQTest(m5, m53);
+ doEQTest(m500, m5003);
+ doEQTest(z3, z2);
+ doEQTest(z1, z2);
+ doEQTest(z1, z3);
+ doLTTest(z1, m1);
+ doLTTest(m2, z2);
+ doLTTest(z3, m1);
+
+ }
/**
* Unit tests for encoding {@link BigInteger} keys.
*/
@@ -2119,7 +2182,7 @@
* Stress test with random byte[]s from which we then construct
* {@link BigDecimal}s.
*/
- public void test_BigDecimal_stress_byteArray_values() {
+ public void badTest_BigDecimal_stress_byteArray_values() {
final Random r = new Random();
@@ -2408,14 +2471,14 @@
new BigDecimal(".0"), // scale=1, precision=1
// NB: The precision is the #of decimal digits in the unscaled value.
// NB: scaled := unscaled * (10 ^ -scale)
- new BigDecimal(".010"), // scale=3, precision=2
- new BigDecimal(".01"), // scale=2, precision=1
- new BigDecimal(".1"), // scale=1, precision=1
- new BigDecimal("1."), // scale=0, precision=1
- new BigDecimal("10."), // scale=0, precision=2
- new BigDecimal("10.0"), // scale=1, precision=3
- new BigDecimal("010.0"), // scale=1, precision=3
- new BigDecimal("0010.00"), // scale=2, precision=4
+// new BigDecimal(".010"), // scale=3, precision=2
+// new BigDecimal(".01"), // scale=2, precision=1
+// new BigDecimal(".1"), // scale=1, precision=1
+// new BigDecimal("1."), // scale=0, precision=1
+// new BigDecimal("10."), // scale=0, precision=2
+// new BigDecimal("10.0"), // scale=1, precision=3
+// new BigDecimal("010.0"), // scale=1, precision=3
+// new BigDecimal("0010.00"), // scale=2, precision=4
// @todo Test with cases where scale is negative (large powers of 10).
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|