[Pkg-bitcoin-commits] [libunivalue] 73/76: Merge pull request #14 from laanwj/2015_11_escape_plan

Jonas Smedegaard dr at jones.dk
Mon Apr 4 09:18:34 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 5e7985a3f86dd4b7354f4c0b749846f62265ea4d
Merge: 46098ee 7482163
Author: Jeff Garzik <jgarzik at dss.co>
Date:   Wed Dec 2 07:53:17 2015 -0500

    Merge pull request #14 from laanwj/2015_11_escape_plan
    
    Escape all control characters

 Makefile.am            |  3 ++-
 gen/gen.cpp            | 14 ++++++++++---
 lib/univalue_escapes.h | 56 +++++++++++++++++++++++++-------------------------
 lib/univalue_write.cpp |  4 ++--
 test/round1.json       |  1 +
 test/unitester.cpp     | 15 +++++++++++++-
 6 files changed, 58 insertions(+), 35 deletions(-)

diff --cc test/unitester.cpp
index fc2f078,c87b86a..5a052fe
--- a/test/unitester.cpp
+++ b/test/unitester.cpp
@@@ -19,26 -19,37 +19,38 @@@
  
  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 std::string rtrim(std::string s)
+ {
+     s.erase(s.find_last_not_of(" \n\r\t")+1);
+     return s;
+ }
+ 
  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");
+         bool wantPass = (prefix == "pass") || (prefix == "roun");
          bool wantFail = (prefix == "fail");
+         bool wantRoundTrip = (prefix == "roun");
          assert(wantPass || wantFail);
  
          UniValue val;
          bool testResult = val.read(jdata);
  
          if (wantPass) {
 -            assert(testResult == true);
 +            d_assert(testResult == true);
          } else {
 -            assert(testResult == false);
 +            d_assert(testResult == false);
          }
+ 
+         if (wantRoundTrip) {
+             std::string odata = val.write(0, 0);
+             assert(odata == rtrim(jdata));
+         }
  }
  
  static void runtest_file(const char *filename_)

-- 
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