[Pkg-bitcoin-commits] [libunivalue] 63/76: test: Improve tester diagnostics. Add failing test case from #15

Jonas Smedegaard dr at jones.dk
Mon Apr 4 09:18:33 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libunivalue.

commit fd448da5269e5d9b7ffe5dd98a36c5a952868d63
Author: Jeff Garzik <jeff at bloq.com>
Date:   Sat Nov 7 10:55:27 2015 -0500

    test: Improve tester diagnostics.  Add failing test case from #15
---
 test/fail35.json   |  1 +
 test/unitester.cpp | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/fail35.json b/test/fail35.json
new file mode 100644
index 0000000..de30ca5
--- /dev/null
+++ b/test/fail35.json
@@ -0,0 +1 @@
+[ true true true [] [] [] ]
diff --git a/test/unitester.cpp b/test/unitester.cpp
index 835556e..73a74d1 100644
--- a/test/unitester.cpp
+++ b/test/unitester.cpp
@@ -19,11 +19,12 @@
 
 using namespace std;
 string srcdir(JSON_TEST_SRC);
+static bool test_failed = false;
+
+#define d_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", filename.c_str()); } }
 
 static void runtest(string filename, const string& jdata)
 {
-        fprintf(stderr, "test %s\n", filename.c_str());
-
         string prefix = filename.substr(0, 4);
 
         bool wantPass = (prefix == "pass");
@@ -34,9 +35,9 @@ static void runtest(string filename, const string& jdata)
         bool testResult = val.read(jdata);
 
         if (wantPass) {
-            assert(testResult == true);
+            d_assert(testResult == true);
         } else {
-            assert(testResult == false);
+            d_assert(testResult == false);
         }
 }
 
@@ -92,6 +93,7 @@ static const char *filenames[] = {
         "fail32.json",
         "fail33.json",
         "fail34.json",
+        // "fail35.json",		// investigate - issue #15
         "fail3.json",
         "fail4.json",                // extra comma
         "fail5.json",
@@ -110,6 +112,6 @@ int main (int argc, char *argv[])
         runtest_file(filenames[fidx]);
     }
 
-    return 0;
+    return test_failed ? 1 : 0;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/libunivalue.git



More information about the Pkg-bitcoin-commits mailing list