diff options
author | fanquake <fanquake@gmail.com> | 2022-06-11 14:29:09 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-06-15 12:56:44 +0100 |
commit | d873ff96e51a3e7f2fdc3fdd1baee2bbe7583e06 (patch) | |
tree | d75c5d34033c6c709985a4697053a31def926533 /src/univalue/test | |
parent | e2aa7047f9b94232ff4958381321e6867d24b379 (diff) | |
download | bitcoin-d873ff96e51a3e7f2fdc3fdd1baee2bbe7583e06.tar.xz |
refactor: cleanups post unsubtree'ing univalue
Mostly changes to remove src/univalue exceptions from the various linters,
and the required code changes to make them happy. As well as minor doc
changes.
Diffstat (limited to 'src/univalue/test')
-rw-r--r-- | src/univalue/test/unitester.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp index 81b1c5d3b1..94c149b39f 100644 --- a/src/univalue/test/unitester.cpp +++ b/src/univalue/test/unitester.cpp @@ -12,15 +12,7 @@ #error JSON_TEST_SRC must point to test source directory #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -#endif - 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()); } } -#define f_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", __func__); } } static std::string rtrim(std::string s) { @@ -41,9 +33,9 @@ static void runtest(std::string filename, const std::string& jdata) bool testResult = val.read(jdata); if (wantPass) { - d_assert(testResult == true); + assert(testResult == true); } else { - d_assert(testResult == false); + assert(testResult == false); } if (wantRoundTrip) { @@ -141,30 +133,30 @@ void unescape_unicode_test() bool testResult; // Escaped ASCII (quote) testResult = val.read("[\"\\u0022\"]"); - f_assert(testResult); - f_assert(val[0].get_str() == "\""); + assert(testResult); + assert(val[0].get_str() == "\""); // Escaped Basic Plane character, two-byte UTF-8 testResult = val.read("[\"\\u0191\"]"); - f_assert(testResult); - f_assert(val[0].get_str() == "\xc6\x91"); + assert(testResult); + assert(val[0].get_str() == "\xc6\x91"); // Escaped Basic Plane character, three-byte UTF-8 testResult = val.read("[\"\\u2191\"]"); - f_assert(testResult); - f_assert(val[0].get_str() == "\xe2\x86\x91"); + assert(testResult); + assert(val[0].get_str() == "\xe2\x86\x91"); // Escaped Supplementary Plane character U+1d161 testResult = val.read("[\"\\ud834\\udd61\"]"); - f_assert(testResult); - f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1"); + assert(testResult); + assert(val[0].get_str() == "\xf0\x9d\x85\xa1"); } int main (int argc, char *argv[]) { - for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) { - runtest_file(filenames[fidx]); + for (const auto& f: filenames) { + runtest_file(f); } unescape_unicode_test(); - return test_failed ? 1 : 0; + return 0; } |