You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/10/27 02:12:55 UTC
[lucy-commits] svn commit: r1027782 -
/incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c
Author: marvin
Date: Wed Oct 27 00:12:54 2010
New Revision: 1027782
URL: http://svn.apache.org/viewvc?rev=1027782&view=rev
Log:
Harden JSON float stringification test against misleading failures.
Modified:
incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c
Modified: incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c?rev=1027782&r1=1027781&r2=1027782&view=diff
==============================================================================
--- incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c (original)
+++ incubator/lucy/trunk/core/KinoSearch/Test/Util/TestJson.c Wed Oct 27 00:12:54 2010
@@ -153,9 +153,16 @@ test_numbers(TestBatch *batch)
Float64 *f64 = Float64_new(33.33);
json = Json_to_json((Obj*)f64);
- CB_Trim(json);
- TEST_TRUE(batch, json && CB_Equals_Str(json, "33.33", 5), "Float");
- DECREF(json);
+ if (json) {
+ double value = CB_To_F64(json);
+ double diff = 33.33 - value;
+ if (diff < 0.0) { diff = 0.0 - diff; }
+ TEST_TRUE(batch, diff < 0.0001, "Float");
+ DECREF(json);
+ }
+ else {
+ FAIL(batch, "Float conversion to json failed.");
+ }
DECREF(i64);
DECREF(f64);