diff options
author | delphij <delphij@FreeBSD.org> | 2015-07-15 19:21:26 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-07-15 19:21:26 +0000 |
commit | 2a25cee78ab1d37e7d2bc40ae675646974d99f56 (patch) | |
tree | b0302ac4be59e104f4e1e54014561a1389397192 /contrib/ntp/tests/libntp/g_octtoint.cpp | |
parent | a0741a75537b2e0514472ac3b28afc55a7846c30 (diff) | |
download | FreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.zip FreeBSD-src-2a25cee78ab1d37e7d2bc40ae675646974d99f56.tar.gz |
MFC r280849,280915-280916,281015-281016,282097,282408,282415,283542,
284864,285169-285170,285435:
ntp 4.2.8p3.
Relnotes: yes
Approved by: re (?)
Diffstat (limited to 'contrib/ntp/tests/libntp/g_octtoint.cpp')
-rw-r--r-- | contrib/ntp/tests/libntp/g_octtoint.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/ntp/tests/libntp/g_octtoint.cpp b/contrib/ntp/tests/libntp/g_octtoint.cpp new file mode 100644 index 0000000..8731eed --- /dev/null +++ b/contrib/ntp/tests/libntp/g_octtoint.cpp @@ -0,0 +1,57 @@ +#include "g_libntptest.h" + +class octtointTest : public libntptest { +}; + +TEST_F(octtointTest, SingleDigit) { + const char* str = "5"; + u_long actual; + + ASSERT_TRUE(octtoint(str, &actual)); + EXPECT_EQ(5, actual); +} + +TEST_F(octtointTest, MultipleDigits) { + const char* str = "271"; + u_long actual; + + ASSERT_TRUE(octtoint(str, &actual)); + EXPECT_EQ(185, actual); +} + +TEST_F(octtointTest, Zero) { + const char* str = "0"; + u_long actual; + + ASSERT_TRUE(octtoint(str, &actual)); + EXPECT_EQ(0, actual); +} + +TEST_F(octtointTest, MaximumUnsigned32bit) { + const char* str = "37777777777"; + u_long actual; + + ASSERT_TRUE(octtoint(str, &actual)); + EXPECT_EQ(4294967295UL, actual); +} + +TEST_F(octtointTest, Overflow) { + const char* str = "40000000000"; + u_long actual; + + ASSERT_FALSE(octtoint(str, &actual)); +} + +TEST_F(octtointTest, IllegalCharacter) { + const char* str = "5ac2"; + u_long actual; + + ASSERT_FALSE(octtoint(str, &actual)); +} + +TEST_F(octtointTest, IllegalDigit) { + const char* str = "5283"; + u_long actual; + + ASSERT_FALSE(octtoint(str, &actual)); +} |