]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2448] add Element::create(uint32_t)
authorAndrei Pavel <andrei@isc.org>
Tue, 28 Jun 2022 14:56:43 +0000 (17:56 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 7 Jul 2022 11:48:20 +0000 (11:48 +0000)
src/lib/cc/data.cc
src/lib/cc/data.h
src/lib/cc/tests/data_unittests.cc

index 02ca6cbff3be08ab933b3e6d2e41d8ec53992f45..20c201548415990c45f6f228ad566f90763499a8 100644 (file)
@@ -257,6 +257,11 @@ Element::create(const long int i, const Position& pos) {
     return (create(static_cast<long long int>(i), pos));
 }
 
+ElementPtr
+Element::create(const uint32_t i, const Position& pos) {
+    return (create(static_cast<long long int>(i), pos));
+}
+
 ElementPtr
 Element::create(const double d, const Position& pos) {
     return (ElementPtr(new DoubleElement(d, pos)));
index 5541259f790ef8b2c2dd3ef0e05fb607198eb3d4..7cb23807138d627f6d4c9a2d3b74581bf74bfb94 100644 (file)
@@ -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,
index 50d4758c034285d719ddd9e57e1ac9ee56a945f5..5aed9a4d78b1bed51164b6b75f3d2a162e215b16 100644 (file)
@@ -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({