[icinga-checkins] icinga.org: icinga2/master: Improve test coverage for the array class

git at icinga.org git at icinga.org
Sun Nov 23 09:50:24 CET 2014


Module: icinga2
Branch: master
Commit: 16cf274efcaf7b48f13f1c39b632047c53168fb0
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=16cf274efcaf7b48f13f1c39b632047c53168fb0

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Sun Nov 23 09:50:11 2014 +0100

Improve test coverage for the array class

---

 lib/base/array.cpp  |   33 ---------------------------------
 lib/base/array.hpp  |    5 -----
 test/CMakeLists.txt |    1 +
 test/base-array.cpp |   12 ++++++++++++
 4 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/lib/base/array.cpp b/lib/base/array.cpp
index 6b4ad21..d9ffbb8 100644
--- a/lib/base/array.cpp
+++ b/lib/base/array.cpp
@@ -201,36 +201,3 @@ Array::Ptr Array::ShallowClone(void) const
 	return clone;
 }
 
-Array::Ptr icinga::MakeArray(const Value& val1)
-{
-	Array::Ptr result = new Array();
-	result->Add(val1);
-	return result;
-}
-
-Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2)
-{
-	Array::Ptr result = new Array();
-	result->Add(val1);
-	result->Add(val2);
-	return result;
-}
-
-Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2, const Value& val3)
-{
-	Array::Ptr result = new Array();
-	result->Add(val1);
-	result->Add(val2);
-	result->Add(val3);
-	return result;
-}
-
-Array::Ptr icinga::MakeArray(const Value& val1, const Value& val2, const Value& val3, const Value& val4)
-{
-	Array::Ptr result = new Array();
-	result->Add(val1);
-	result->Add(val2);
-	result->Add(val3);
-	result->Add(val4);
-	return result;
-}
diff --git a/lib/base/array.hpp b/lib/base/array.hpp
index e721cc0..dc18ef2 100644
--- a/lib/base/array.hpp
+++ b/lib/base/array.hpp
@@ -79,11 +79,6 @@ inline Array::Iterator range_end(Array::Ptr x)
 	return x->End();
 }
 
-I2_BASE_API Array::Ptr MakeArray(const Value& val1);
-I2_BASE_API Array::Ptr MakeArray(const Value& val1, const Value& val2);
-I2_BASE_API Array::Ptr MakeArray(const Value& val1, const Value& val2, const Value& val3);
-I2_BASE_API Array::Ptr MakeArray(const Value& val1, const Value& val2, const Value& val3, const Value& val4);
-
 }
 
 namespace boost
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 099cec2..beacbf5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -36,6 +36,7 @@ add_boost_test(base
   LIBRARIES base config icinga
   TESTS base_array/construct
         base_array/getset
+        base_array/resize
         base_array/insert
         base_array/remove
         base_array/foreach
diff --git a/test/base-array.cpp b/test/base-array.cpp
index 6e2077b..10d584a 100644
--- a/test/base-array.cpp
+++ b/test/base-array.cpp
@@ -53,6 +53,15 @@ BOOST_AUTO_TEST_CASE(getset)
 	BOOST_CHECK(array->Get(1) == 5);
 }
 
+BOOST_AUTO_TEST_CASE(resize)
+{
+	Array::Ptr array = new Array();
+	array->Resize(2);
+	BOOST_CHECK(array->GetLength() == 2);
+	BOOST_CHECK(array->Get(0) == Empty);
+	BOOST_CHECK(array->Get(1) == Empty);
+}
+
 BOOST_AUTO_TEST_CASE(insert)
 {
 	Array::Ptr array = new Array();
@@ -89,6 +98,9 @@ BOOST_AUTO_TEST_CASE(remove)
 
 	BOOST_CHECK(array->GetLength() == 2);
 	BOOST_CHECK(array->Get(0) == 2);
+
+	array->Clear();
+	BOOST_CHECK(array->GetLength() == 0);
 }
 
 BOOST_AUTO_TEST_CASE(foreach)



More information about the icinga-checkins mailing list