Skip to content

Commit

Permalink
[test] add a couple test cases to uint256_tests.cpp
Browse files Browse the repository at this point in the history
Summary:
make sure `template <unsigned int BITS> void base_blob<BITS>::SetHex(const char *psz)` properly skips
leading spaces and `0x` prefixes

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6323
  • Loading branch information
majcosta authored and ftrader committed Jul 3, 2020
1 parent 6342f98 commit b68a87f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/uint256_tests.cpp
Expand Up @@ -263,6 +263,18 @@ BOOST_AUTO_TEST_CASE(methods) {
ss >> TmpS;
BOOST_CHECK(MaxS == TmpS);
ss.clear();

// Check that '0x' or '0X', and leading spaces are correctly skipped in
// SetHex
const auto baseHexstring{uint256S(
"0x7d1de5eaf9b156d53208f033b5aa8122d2d2355d5e12292b121156cfdb4a529c")};
const auto hexstringWithCharactersToSkip{uint256S(
" 0X7d1de5eaf9b156d53208f033b5aa8122d2d2355d5e12292b121156cfdb4a529c")};
const auto wrongHexstringWithCharactersToSkip{uint256S(
" 0X7d1de5eaf9b156d53208f033b5aa8122d2d2355d5e12292b121156cfdb4a529d")};

BOOST_CHECK(baseHexstring == hexstringWithCharactersToSkip);
BOOST_CHECK(baseHexstring != wrongHexstringWithCharactersToSkip);
}

BOOST_AUTO_TEST_CASE(conversion) {
Expand Down

0 comments on commit b68a87f

Please sign in to comment.