Changeset View
Changeset View
Standalone View
Standalone View
src/test/cashaddr_tests.cpp
- This file was added.
// Copyright (c) 2017 Pieter Wuille | |||||
// Copyright (c) 2017 The Bitcoin developers | |||||
// Distributed under the MIT software license, see the accompanying | |||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | |||||
#include "cashaddr.h" | |||||
#include "test/test_bitcoin.h" | |||||
#include <boost/test/unit_test.hpp> | |||||
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(bip173_testvectors_valid) { | |||||
static const std::string CASES[] = { | |||||
}; | |||||
for (const std::string &str : CASES) { | |||||
auto ret = cashaddr::Decode(str); | |||||
BOOST_CHECK_MESSAGE(!ret.first.empty(), str); | |||||
std::string recode = cashaddr::Encode(ret.first, ret.second); | |||||
BOOST_CHECK(!recode.empty()); | |||||
BOOST_CHECK(CaseInsensitiveEqual(str, recode)); | |||||
} | |||||
} | |||||
BOOST_AUTO_TEST_CASE(cashaddr_testvectors_invalid) { | |||||
static const std::string CASES[] = { | |||||
}; | |||||
for (const std::string &str : CASES) { | |||||
auto ret = cashaddr::Decode(str); | |||||
BOOST_CHECK(ret.first.empty()); | |||||
} | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() |