Skip to content

Instantly share code, notes, and snippets.

@kaykurokawa
Created September 26, 2018 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaykurokawa/2c35843eb09da2bc8f31ffac46de4099 to your computer and use it in GitHub Desktop.
Save kaykurokawa/2c35843eb09da2bc8f31ffac46de4099 to your computer and use it in GitHub Desktop.
Test the normalization function
#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