From: Jan Fajerski Date: Sat, 21 Apr 2018 09:27:17 +0000 (+0200) Subject: test/strtol: add test case for parsing hex numbers X-Git-Tag: v14.0.0~201^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=dc081d49c85b74d2436cc3e2f6a1a8eb63234a5a;p=ceph.git test/strtol: add test case for parsing hex numbers Signed-off-by: Jan Fajerski --- diff --git a/src/test/strtol.cc b/src/test/strtol.cc index 69d1a70871e0a..673bf2977f416 100644 --- a/src/test/strtol.cc +++ b/src/test/strtol.cc @@ -19,10 +19,10 @@ #include "gtest/gtest.h" -static void test_strict_strtoll(const char *str, long long expected) +static void test_strict_strtoll(const char *str, long long expected, int base) { std::string err; - long long val = strict_strtoll(str, 10, &err); + long long val = strict_strtoll(str, base, &err); if (!err.empty()) { ASSERT_EQ(err, ""); } @@ -74,11 +74,14 @@ static void test_strict_strtof(const char *str, float expected) } TEST(StrToL, Simple1) { - test_strict_strtoll("123", 123); - test_strict_strtoll("0", 0); - test_strict_strtoll("-123", -123); - test_strict_strtoll("8796093022208", 8796093022208LL); - test_strict_strtoll("-8796093022208", -8796093022208LL); + test_strict_strtoll("123", 123, 10); + test_strict_strtoll("0", 0, 10); + test_strict_strtoll("-123", -123, 10); + test_strict_strtoll("8796093022208", 8796093022208LL, 10); + test_strict_strtoll("-8796093022208", -8796093022208LL, 10); + test_strict_strtoll("123", 123, 0); + test_strict_strtoll("0x7b", 123, 0); + test_strict_strtoll("4d2", 1234, 16); test_strict_strtol("208", 208); test_strict_strtol("-4", -4);