Improve test coverage for the array class

This commit is contained in:
Gunnar Beutner 2014-11-23 09:50:11 +01:00
parent 9bdc7e8a4e
commit 16cf274efc
4 changed files with 13 additions and 38 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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)