From: Linux Karlsson Date: Tue, 15 Jun 2010 10:05:16 +0000 (+0200) Subject: Added inttoa tests. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2dc9843c99ff511d7f26e7aa92d524a0782dcda2;p=thirdparty%2Fntp.git Added inttoa tests. bk: 4c17505cDDH6dLx17Z3lgixT3UeNVg --- diff --git a/tests/libntp/Makefile.am b/tests/libntp/Makefile.am index ff6f24dd6b..f20880edf8 100644 --- a/tests/libntp/Makefile.am +++ b/tests/libntp/Makefile.am @@ -13,6 +13,7 @@ tests_SOURCES = ../main.cpp \ decodenetnum.cpp \ hextoint.cpp \ hextolfp.cpp \ + inttoa.cpp \ lfptostr.cpp \ sfptostr.cpp diff --git a/tests/libntp/inttoa.cpp b/tests/libntp/inttoa.cpp new file mode 100644 index 0000000000..05ea88cadb --- /dev/null +++ b/tests/libntp/inttoa.cpp @@ -0,0 +1,24 @@ +#include "libntptest.h" + +class inttoaTest : public libntptest { +}; + +TEST_F(inttoaTest, RegularNumber) { + EXPECT_STREQ("42", inttoa(42)); +} + +TEST_F(inttoaTest, NegativeNumber) { + EXPECT_STREQ("-3", inttoa(-3)); +} + +TEST_F(inttoaTest, BigPositiveNumber) { + EXPECT_STREQ("2147483647", inttoa(2147483647)); +} + +TEST_F(inttoaTest, BigNegativeNumber) { + EXPECT_STREQ("-2147483648", inttoa(-2147483648)); +} + +TEST_F(inttoaTest, MediumNumber) { + EXPECT_STREQ("20000001", inttoa(20000001)); +}