Web Wispers 1.2.1 C++ Unit Test Coverage
Current view: top level - tests/wispers/lua - LoadConfigTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.1 C++ Unit Tests Lines: 37 37 100.0 %
Date: 2011-11-11 Functions: 13 14 92.9 %
Branches: 246 596 41.3 %

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