diff --git a/src/Makefile.test.include b/src/Makefile.test.include --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -78,8 +78,12 @@ avalanche/test/util.cpp \ test/fixture.cpp \ test/jsonutil.cpp \ + test/util/setup_common.h \ + test/util/setup_common.cpp \ test/scriptflags.cpp \ test/sigutil.cpp \ + test/util/str.h \ + test/util/str.cpp \ $(TEST_UTIL_H) FUZZ_SUITE = \ diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -50,6 +50,7 @@ util/blockfilter.cpp util/logging.cpp util/setup_common.cpp + util/str.cpp util/transaction_utils.cpp ) diff --git a/src/test/cashaddr_tests.cpp b/src/test/cashaddr_tests.cpp --- a/src/test/cashaddr_tests.cpp +++ b/src/test/cashaddr_tests.cpp @@ -6,6 +6,7 @@ #include #include +#include #include @@ -16,28 +17,6 @@ BOOST_FIXTURE_TEST_SUITE(cashaddr_tests, BasicTestingSetup) -bool CaseInsensitiveEqual(const std::string &s1, const std::string &s2) { - if (s1.size() != s2.size()) { - return false; - } - - for (size_t i = 0; i < s1.size(); ++i) { - char c1 = s1[i]; - if (c1 >= 'A' && c1 <= 'Z') { - c1 -= ('A' - 'a'); - } - char c2 = s2[i]; - if (c2 >= 'A' && c2 <= 'Z') { - c2 -= ('A' - 'a'); - } - if (c1 != c2) { - return false; - } - } - - return true; -} - BOOST_AUTO_TEST_CASE(cashaddr_testvectors_valid) { static const std::string CASES[] = { "prefix:x64nx6hz", diff --git a/src/test/util/str.h b/src/test/util/str.h new file mode 100644 --- /dev/null +++ b/src/test/util/str.h @@ -0,0 +1,12 @@ +// Copyright (c) 2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TEST_UTIL_STR_H +#define BITCOIN_TEST_UTIL_STR_H + +#include + +bool CaseInsensitiveEqual(const std::string &s1, const std::string &s2); + +#endif // BITCOIN_TEST_UTIL_STR_H diff --git a/src/test/util/str.cpp b/src/test/util/str.cpp new file mode 100644 --- /dev/null +++ b/src/test/util/str.cpp @@ -0,0 +1,30 @@ +// Copyright (c) 2019 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include +#include + +bool CaseInsensitiveEqual(const std::string &s1, const std::string &s2) { + if (s1.size() != s2.size()) { + return false; + } + + for (size_t i = 0; i < s1.size(); ++i) { + char c1 = s1[i]; + if (c1 >= 'A' && c1 <= 'Z') { + c1 -= ('A' - 'a'); + } + char c2 = s2[i]; + if (c2 >= 'A' && c2 <= 'Z') { + c2 -= ('A' - 'a'); + } + if (c1 != c2) { + return false; + } + } + + return true; +}