1 /******************************************************************************
3 * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "base/dictionary.h"
21 #include <boost/test/unit_test.hpp>
22 #include <boost/smart_ptr/make_shared.hpp>
24 using namespace icinga;
26 BOOST_AUTO_TEST_SUITE(base_dictionary)
28 BOOST_AUTO_TEST_CASE(construct)
30 Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
31 BOOST_CHECK(dictionary);
34 BOOST_AUTO_TEST_CASE(getproperty)
36 Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
37 dictionary->Set("test1", 7);
38 dictionary->Set("test2", "hello world");
41 test1 = dictionary->Get("test1");
42 BOOST_CHECK(test1 == 7);
45 test2 = dictionary->Get("test2");
46 BOOST_CHECK(test2 == "hello world");
49 test3 = dictionary->Get("test3");
50 BOOST_CHECK(test3.IsEmpty());
53 BOOST_AUTO_TEST_CASE(getproperty_dict)
55 Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
56 Dictionary::Ptr other = boost::make_shared<Dictionary>();
58 dictionary->Set("test1", other);
60 Dictionary::Ptr test1 = dictionary->Get("test1");
61 BOOST_CHECK(other == test1);
63 Dictionary::Ptr test2 = dictionary->Get("test2");
67 BOOST_AUTO_TEST_SUITE_END()