2013-02-08 06:49:23 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-03-18 11:15:46 +01:00
|
|
|
#include "base/dictionary.h"
|
2012-05-28 11:53:51 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2013-03-18 11:15:46 +01:00
|
|
|
#include <boost/smart_ptr/make_shared.hpp>
|
2013-02-08 06:49:23 +01:00
|
|
|
|
2012-05-28 11:53:51 +02:00
|
|
|
using namespace icinga;
|
|
|
|
|
2013-02-08 06:49:23 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE(base_dictionary)
|
|
|
|
|
2012-05-28 11:53:51 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(construct)
|
|
|
|
{
|
2012-07-10 09:44:11 +02:00
|
|
|
Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(dictionary);
|
2012-05-28 11:53:51 +02:00
|
|
|
}
|
|
|
|
|
2012-05-29 06:25:01 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(getproperty)
|
2012-05-28 11:53:51 +02:00
|
|
|
{
|
2012-07-10 09:44:11 +02:00
|
|
|
Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
|
2012-07-09 16:19:56 +02:00
|
|
|
dictionary->Set("test1", 7);
|
|
|
|
dictionary->Set("test2", "hello world");
|
2012-05-28 11:53:51 +02:00
|
|
|
|
2012-09-14 11:41:15 +02:00
|
|
|
Value test1;
|
|
|
|
test1 = dictionary->Get("test1");
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(test1 == 7);
|
2012-05-28 11:53:51 +02:00
|
|
|
|
2012-09-14 11:41:15 +02:00
|
|
|
Value test2;
|
|
|
|
test2 = dictionary->Get("test2");
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(test2 == "hello world");
|
2012-05-29 06:25:01 +02:00
|
|
|
|
2012-09-14 11:41:15 +02:00
|
|
|
Value test3;
|
|
|
|
test3 = dictionary->Get("test3");
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(test3.IsEmpty());
|
2012-05-29 06:25:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(getproperty_dict)
|
|
|
|
{
|
2012-07-10 09:44:11 +02:00
|
|
|
Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
|
|
|
|
Dictionary::Ptr other = boost::make_shared<Dictionary>();
|
2012-05-29 06:25:01 +02:00
|
|
|
|
2012-07-09 16:19:56 +02:00
|
|
|
dictionary->Set("test1", other);
|
2012-05-29 06:25:01 +02:00
|
|
|
|
2012-09-14 11:41:15 +02:00
|
|
|
Dictionary::Ptr test1 = dictionary->Get("test1");
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(other == test1);
|
2012-05-29 06:25:01 +02:00
|
|
|
|
2012-09-14 11:41:15 +02:00
|
|
|
Dictionary::Ptr test2 = dictionary->Get("test2");
|
2013-02-07 11:13:00 +01:00
|
|
|
BOOST_CHECK(!test2);
|
2012-05-29 06:25:01 +02:00
|
|
|
}
|
|
|
|
|
2013-02-08 06:49:23 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|