]> granicus.if.org Git - icinga2/commitdiff
Implement unit tests for Dictionary initializers 6771/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 9 Nov 2018 13:56:36 +0000 (14:56 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 9 Nov 2018 13:56:36 +0000 (14:56 +0100)
test/CMakeLists.txt
test/base-dictionary.cpp

index 766d15a2e13cae3578f6258bbb77ff239e974b5d..c78f2732d7f26d5876e3a0d69cd3f6525440a964 100644 (file)
@@ -73,6 +73,8 @@ add_boost_test(base
     base_convert/tostring
     base_convert/tobool
     base_dictionary/construct
+    base_dictionary/initializer1
+    base_dictionary/initializer2
     base_dictionary/get1
     base_dictionary/get2
     base_dictionary/foreach
index 1eb5a1b7ed3ed235b1f23a34ff1fe03c6f33d700..79d736f0ac4e8a58330e1c5154586204b6368005 100644 (file)
@@ -32,6 +32,28 @@ BOOST_AUTO_TEST_CASE(construct)
        BOOST_CHECK(dictionary);
 }
 
+BOOST_AUTO_TEST_CASE(initializer1)
+{
+       DictionaryData dict;
+
+       dict.emplace_back("test1", "Gin-o-clock");
+
+       Dictionary::Ptr dictionary = new Dictionary(std::move(dict));
+
+       Value test1;
+       test1 = dictionary->Get("test1");
+       BOOST_CHECK(test1 == "Gin-o-clock");
+}
+
+BOOST_AUTO_TEST_CASE(initializer2)
+{
+       Dictionary::Ptr dictionary = new Dictionary({ {"test1", "Gin-for-the-win"} });
+
+       Value test1;
+       test1 = dictionary->Get("test1");
+       BOOST_CHECK(test1 == "Gin-for-the-win");
+}
+
 BOOST_AUTO_TEST_CASE(get1)
 {
        Dictionary::Ptr dictionary = new Dictionary();