Web Wispers 1.2.2 C++ Unit Test Coverage |
|
|
|
|
Branch data Line data Source code
1 : : /* Copyright 2006-2009 Savarese Software Research Corporation
2 : : *
3 : : * Licensed under the Apache License, Version 2.0 (the "License");
4 : : * you may not use this file except in compliance with the License.
5 : : * You may obtain a copy of the License at
6 : : *
7 : : * https://www.savarese.com/software/ApacheLicense-2.0
8 : : *
9 : : * Unless required by applicable law or agreed to in writing, software
10 : : * distributed under the License is distributed on an "AS IS" BASIS,
11 : : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : : * See the License for the specific language governing permissions and
13 : : * limitations under the License.
14 : : */
15 : :
16 : : #include <ssrc/wispers/lua/LoadConfig.h>
17 : : #include "table_lua.h"
18 : :
19 : : #define BOOST_TEST_MODULE LoadConfigTest
20 : : #include <boost/test/unit_test.hpp>
21 : :
22 : : using ssrc::wispers::utility::primitive_property_vector;
23 : : using ssrc::wispers::utility::property_vector;
24 : : using namespace NS_SSRC_WSPR_LUA;
25 : :
26 : 2 : void test_load_config(const properties_ptr & properties) {
27 [ + - + - : 2 : BOOST_CHECK(*properties->get_ptr<string>("test", "string") == "/tmp");
+ - + - +
- - + ]
28 [ + - + - : 2 : BOOST_CHECK(*properties->get_ptr<lua_Number>("test", "number") == 12);
+ - + - -
+ ]
29 [ + - + - : 2 : BOOST_CHECK(*properties->get_ptr<bool>("test", "bool") == true);
+ - + - -
+ ]
30 [ + - + - : 2 : BOOST_CHECK(*properties->get_ptr<string>("test", "node", "a") == "A");
+ - + - +
- - + ]
31 [ + - + - : 2 : BOOST_CHECK(*properties->get_ptr<string>("test", "node", "b") == "B");
+ - + - +
- - + ]
32 : :
33 : : primitive_property_vector *ppv =
34 : 2 : properties->get_ptr<primitive_property_vector>("test","primitive_vector");
35 : :
36 [ + - + - : 2 : BOOST_CHECK(ppv != 0);
+ - - + ]
37 [ + - + - : 2 : BOOST_CHECK(ppv->size() == 3);
+ - + - -
+ ]
38 [ + - + - : 2 : BOOST_CHECK(boost::get<lua_Number>((*ppv)[0]) == 1);
+ - + - +
- - + ]
39 [ + - + - : 2 : BOOST_CHECK(boost::get<lua_Number>((*ppv)[1]) == 2);
+ - + - +
- - + ]
40 [ + - + - : 2 : BOOST_CHECK(boost::get<lua_Number>((*ppv)[2]) == 3);
+ - + - +
- - + ]
41 : :
42 : : property_vector *pv =
43 : 2 : properties->get_ptr<property_vector>("test", "property_vector");
44 : :
45 [ + - + - : 2 : BOOST_CHECK(pv != 0);
+ - - + ]
46 [ + - + - : 2 : BOOST_CHECK(pv->size() == 2);
+ - + - -
+ ]
47 [ + - + - : 2 : BOOST_CHECK(*pv->at(0).get_ptr<lua_Number>("value") == 1);
+ - + - +
- - + ]
48 [ + - + - : 2 : BOOST_CHECK(*pv->at(1).get_ptr<lua_Number>("value") == 2);
+ - + - +
- - + ]
49 : 2 : }
50 : :
51 [ + - + - ]: 3 : BOOST_AUTO_TEST_CASE(test_load_config1) {
52 [ + - + - ]: 2 : LoadConfig load(CONFIG_SO_DIR);
53 [ + - + - ]: 2 : properties_ptr properties;
54 : :
55 [ + - + - : 1 : BOOST_CHECK_NO_THROW(properties = load(TABLE_LUA));
+ - + - +
- + - + -
+ - + - +
- + - + -
- + # # #
# # # # #
# # # # #
# # # #
# ]
56 : :
57 [ + - ]: 1 : test_load_config(properties);
58 : 1 : }
59 : :
60 [ + - + - : 3 : BOOST_AUTO_TEST_CASE(test_load_config2) {
- + # # ]
61 [ + - + - ]: 2 : LoadConfig load(CONFIG_SO_DIR);
62 [ + - + - ]: 2 : properties_ptr properties;
63 : :
64 [ + - + - : 1 : BOOST_CHECK_NO_THROW(properties = load.load_from_string(TABLE_LUA_STR));
+ - + - +
- + - + -
+ - + - +
- + - + -
- + # # #
# # # # #
# # # # #
# # # #
# ]
65 : :
66 [ + - ]: 1 : test_load_config(properties);
67 [ + - + - ]: 4 : }
|
Copyright © 2017 Savarese Software Research Corporation. All rights reserved