From: Andrei Pavel Date: Tue, 28 Jun 2022 14:56:43 +0000 (+0300) Subject: [#2448] add Element::create(uint32_t) X-Git-Tag: Kea-2.2.0~82 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7c136b4bfcd47e14b9e85f82bf7904d51059300;p=thirdparty%2Fkea.git [#2448] add Element::create(uint32_t) --- diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 02ca6cbff3..20c2015484 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -257,6 +257,11 @@ Element::create(const long int i, const Position& pos) { return (create(static_cast(i), pos)); } +ElementPtr +Element::create(const uint32_t i, const Position& pos) { + return (create(static_cast(i), pos)); +} + ElementPtr Element::create(const double d, const Position& pos) { return (ElementPtr(new DoubleElement(d, pos))); diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index 5541259f79..7cb2380713 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -380,6 +380,8 @@ public: const Position& pos = ZERO_POSITION()); static ElementPtr create(const long int i, const Position& pos = ZERO_POSITION()); + static ElementPtr create(const uint32_t i, + const Position& pos = ZERO_POSITION()); static ElementPtr create(const double d, const Position& pos = ZERO_POSITION()); static ElementPtr create(const bool b, diff --git a/src/lib/cc/tests/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc index 50d4758c03..5aed9a4d78 100644 --- a/src/lib/cc/tests/data_unittests.cc +++ b/src/lib/cc/tests/data_unittests.cc @@ -212,6 +212,7 @@ testGetValueInt() { T el; int64_t i; int32_t i32; + uint32_t ui32; long l; long long ll; double d; @@ -260,6 +261,14 @@ testGetValueInt() { EXPECT_TRUE(el->getValue(i)); EXPECT_EQ(i32, i); + ui32 = 4294967295L; + el = Element::create(ui32); + EXPECT_NO_THROW({ + EXPECT_EQ(ui32, el->intValue()); + }); + EXPECT_TRUE(el->getValue(i)); + EXPECT_EQ(ui32, i); + l = 2147483647L; el = Element::create(l); EXPECT_NO_THROW({