aboutsummaryrefslogtreecommitdiff
path: root/src/test/util_tests.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-05-09 17:26:16 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-09 17:26:42 +0200
commit605d5b55582f00ea8a089fe632cd8a52e951126b (patch)
treec92db0c674fb1adf9f3a8f0c743547af1db59523 /src/test/util_tests.cpp
parent8bcfccbc2de25e3b40d1c222d7c5d9991345a0aa (diff)
parent21bf3d257b88c45e2bb0b47e36e73d7462760c2c (diff)
Merge pull request #4102
21bf3d2 Add tests for BoostAsioToCNetAddr (Wladimir J. van der Laan) fdbd707 Remove unused function WildcardMatch (Wladimir J. van der Laan) ee21912 rpc: Use netmasks instead of wildcards for IP address matching (Wladimir J. van der Laan) e16be73 net: Add CSubNet class for subnet matching (Wladimir J. van der Laan) d864275 Use new function parseint32 in SplitHostPort (Wladimir J. van der Laan) 0d4ea1c util: add parseint32 function with strict error reporting (Wladimir J. van der Laan)
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r--src/test/util_tests.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index b8f107f644..f4ca8c0539 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -165,17 +165,6 @@ BOOST_AUTO_TEST_CASE(util_GetArg)
BOOST_CHECK_EQUAL(GetBoolArg("booltest4", false), true);
}
-BOOST_AUTO_TEST_CASE(util_WildcardMatch)
-{
- BOOST_CHECK(WildcardMatch("127.0.0.1", "*"));
- BOOST_CHECK(WildcardMatch("127.0.0.1", "127.*"));
- BOOST_CHECK(WildcardMatch("abcdef", "a?cde?"));
- BOOST_CHECK(!WildcardMatch("abcdef", "a?cde??"));
- BOOST_CHECK(WildcardMatch("abcdef", "a*f"));
- BOOST_CHECK(!WildcardMatch("abcdef", "a*x"));
- BOOST_CHECK(WildcardMatch("", "*"));
-}
-
BOOST_AUTO_TEST_CASE(util_FormatMoney)
{
BOOST_CHECK_EQUAL(FormatMoney(0, false), "0.00");
@@ -342,4 +331,26 @@ BOOST_AUTO_TEST_CASE(gettime)
BOOST_CHECK((GetTime() & ~0xFFFFFFFFLL) == 0);
}
+BOOST_AUTO_TEST_CASE(test_ParseInt32)
+{
+ int32_t n;
+ // Valid values
+ BOOST_CHECK(ParseInt32("1234", NULL));
+ BOOST_CHECK(ParseInt32("0", &n) && n == 0);
+ BOOST_CHECK(ParseInt32("1234", &n) && n == 1234);
+ BOOST_CHECK(ParseInt32("01234", &n) && n == 1234); // no octal
+ BOOST_CHECK(ParseInt32("2147483647", &n) && n == 2147483647);
+ BOOST_CHECK(ParseInt32("-2147483648", &n) && n == -2147483648);
+ BOOST_CHECK(ParseInt32("-1234", &n) && n == -1234);
+ // Invalid values
+ BOOST_CHECK(!ParseInt32("1a", &n));
+ BOOST_CHECK(!ParseInt32("aap", &n));
+ BOOST_CHECK(!ParseInt32("0x1", &n)); // no hex
+ // Overflow and underflow
+ BOOST_CHECK(!ParseInt32("-2147483649", NULL));
+ BOOST_CHECK(!ParseInt32("2147483648", NULL));
+ BOOST_CHECK(!ParseInt32("-32482348723847471234", NULL));
+ BOOST_CHECK(!ParseInt32("32482348723847471234", NULL));
+}
+
BOOST_AUTO_TEST_SUITE_END()