aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-04-19 23:25:44 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-05-09 16:39:48 +0200
commit4d480c8a3fe3c58eeb083ea544c6f9e991606692 (patch)
treea071a58cad8b798c51f9c3eb9e96b0ae84e1be0b /src/test
parenteb2cbd754d0ed02ab1c3f0889b6ee1776abd5082 (diff)
Exception instead of assigning 0 in case of wrong vector length
Diffstat (limited to 'src/test')
-rw-r--r--src/test/uint256_tests.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp
index 815babf107..8e4b63c8bc 100644
--- a/src/test/uint256_tests.cpp
+++ b/src/test/uint256_tests.cpp
@@ -160,11 +160,11 @@ BOOST_AUTO_TEST_CASE( basics ) // constructors, equality, inequality
tmpS = ~R2S; BOOST_CHECK(tmpS == ~R2S);
tmpS = ~MaxS; BOOST_CHECK(tmpS == ~MaxS);
- // Wrong length must give 0
- BOOST_CHECK(uint256(std::vector<unsigned char>(OneArray,OneArray+31)) == 0);
- BOOST_CHECK(uint256(std::vector<unsigned char>(OneArray,OneArray+20)) == 0);
- BOOST_CHECK(uint160(std::vector<unsigned char>(OneArray,OneArray+32)) == 0);
- BOOST_CHECK(uint160(std::vector<unsigned char>(OneArray,OneArray+19)) == 0);
+ // Wrong length must throw exception.
+ BOOST_CHECK_THROW(uint256(std::vector<unsigned char>(OneArray,OneArray+31)), uint_error);
+ BOOST_CHECK_THROW(uint256(std::vector<unsigned char>(OneArray,OneArray+20)), uint_error);
+ BOOST_CHECK_THROW(uint160(std::vector<unsigned char>(OneArray,OneArray+32)), uint_error);
+ BOOST_CHECK_THROW(uint160(std::vector<unsigned char>(OneArray,OneArray+19)), uint_error);
}
void shiftArrayRight(unsigned char* to, const unsigned char* from, unsigned int arrayLength, unsigned int bitsToShift)