mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
test: clang-format -i src/univalue/test/unitester.cpp
This commit is contained in:
parent
fafa9cc7a5
commit
faf7eac364
1 changed files with 18 additions and 18 deletions
|
@ -68,32 +68,32 @@
|
||||||
|
|
||||||
static std::string rtrim(std::string s)
|
static std::string rtrim(std::string s)
|
||||||
{
|
{
|
||||||
s.erase(s.find_last_not_of(" \n\r\t")+1);
|
s.erase(s.find_last_not_of(" \n\r\t") + 1);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runtest(std::string filename, const std::string& jdata)
|
static void runtest(std::string filename, const std::string& jdata)
|
||||||
{
|
{
|
||||||
std::string prefix = filename.substr(0, 4);
|
std::string prefix = filename.substr(0, 4);
|
||||||
|
|
||||||
bool wantPass = (prefix == "pass") || (prefix == "roun");
|
bool wantPass = (prefix == "pass") || (prefix == "roun");
|
||||||
bool wantFail = (prefix == "fail");
|
bool wantFail = (prefix == "fail");
|
||||||
bool wantRoundTrip = (prefix == "roun");
|
bool wantRoundTrip = (prefix == "roun");
|
||||||
assert(wantPass || wantFail);
|
assert(wantPass || wantFail);
|
||||||
|
|
||||||
UniValue val;
|
UniValue val;
|
||||||
bool testResult = val.read(jdata);
|
bool testResult = val.read(jdata);
|
||||||
|
|
||||||
if (wantPass) {
|
if (wantPass) {
|
||||||
assert(testResult == true);
|
assert(testResult == true);
|
||||||
} else {
|
} else {
|
||||||
assert(testResult == false);
|
assert(testResult == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantRoundTrip) {
|
if (wantRoundTrip) {
|
||||||
std::string odata = val.write(0, 0);
|
std::string odata = val.write(0, 0);
|
||||||
assert(odata == rtrim(jdata));
|
assert(odata == rtrim(jdata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_FILE(name) {#name, json_tests::name}
|
#define TEST_FILE(name) {#name, json_tests::name}
|
||||||
|
@ -185,7 +185,7 @@ void no_nul_test()
|
||||||
assert(val.read({buf + 3, 7}));
|
assert(val.read({buf + 3, 7}));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
for (const auto& [file, json] : tests) {
|
for (const auto& [file, json] : tests) {
|
||||||
runtest(std::string{file}, std::string{json});
|
runtest(std::string{file}, std::string{json});
|
||||||
|
|
Loading…
Add table
Reference in a new issue