Created
September 26, 2018 23:20
-
-
Save kaykurokawa/2c35843eb09da2bc8f31ffac46de4099 to your computer and use it in GitHub Desktop.
Test the normalization function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "claimtrie.h" | |
#include "test/test_bitcoin.h" | |
#include <boost/test/unit_test.hpp> | |
using namespace std; | |
BOOST_FIXTURE_TEST_SUITE(claimtrienormalize_tests, RegTestingSetup) | |
void print_hex(std::string header,std::string str){ | |
std::cout<<header<<":"; | |
for(int i=0;i<str.size();i++) | |
printf("%02X",(unsigned char)str[i]); | |
std::cout<<"\n"; | |
} | |
// test the normalizeClaimName function | |
BOOST_AUTO_TEST_CASE(normalize_func_test) | |
{ | |
std::string out= normalizeClaimName("a"); | |
print_hex("a",out); | |
//this should be invalid | |
out = normalizeClaimName("\xFF"); | |
print_hex("0xFF",out); | |
std::string replacement = "\uFFFD"; | |
print_hex("replacement",replacement); | |
//this should be invalid | |
out= normalizeClaimName("\xc3\x28"); | |
print_hex("invalid",out); | |
} | |
BOOST_AUTO_TEST_SUITE_END() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment