00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/ConfigUnitTest.cpp $ 00003 // $Id: ConfigUnitTest.cpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Unit test for the Config class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Config.hpp" 00021 00022 namespace torc { 00023 namespace physical { 00024 00025 BOOST_AUTO_TEST_SUITE(physical) 00026 00027 /// \brief Unit test for the Config class. 00028 BOOST_AUTO_TEST_CASE(ConfigUnitTest) { 00029 // functions tested: 00030 // Config(const string& inName, const string& inValue); 00031 // Config(const string& inName, const string& inValue, SequenceIndex inOrder); 00032 // Config(void); 00033 // create a config 00034 std::string name1 = "name1"; 00035 std::string name2 = "name2"; 00036 std::string name3 = "name3"; 00037 std::string value1 = "value1"; 00038 std::string value2 = "value2"; 00039 std::string value3 = "value3"; 00040 SequenceIndex order1(0); 00041 SequenceIndex order2(9); 00042 SequenceIndex order3(10); 00043 Config config1(name1, value1); 00044 Config config2("name3", "value3", order2); 00045 Config config3; 00046 00047 // functions tested: 00048 // const string& Named::getName(void) const; 00049 // const string& getValue(void) const; 00050 // SequenceIndex getOrder(void) const; 00051 // void setOrder(SequenceIndex inOrder); 00052 BOOST_CHECK_EQUAL(config1.getName(), name1); 00053 BOOST_CHECK_EQUAL(config1.getValue(), value1); 00054 config3.setOrder(order3); 00055 BOOST_CHECK(config1.getOrder() == order1); 00056 BOOST_CHECK(config2.getOrder() == order2); 00057 BOOST_CHECK(config3.getOrder() == order3); 00058 00059 // functions tested: 00060 // void setValue(const string& inValue); 00061 // void setName(const string& inName); 00062 // const string& Named::getName(void) const; 00063 // const string& getValue(void) const; 00064 config1.setName(name2); 00065 config1.setValue(value2); 00066 BOOST_CHECK_EQUAL(config1.getName(), name2); 00067 BOOST_CHECK_EQUAL(config1.getValue(), value2); 00068 00069 // functions tested: 00070 // bool operator ==(const Config& rhs) const; 00071 BOOST_CHECK((config1 == config2) == false); 00072 } 00073 00074 BOOST_AUTO_TEST_SUITE_END() 00075 00076 } // namespace physical 00077 } // namespace torc