Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - tests/wispers/utility - DynamicLibraryTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 7 7 100.0 %
Date: 2012-04-09 Functions: 4 4 100.0 %
Branches: 33 66 50.0 %

           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                 :            : #define BOOST_TEST_MODULE DynamicLibraryTest
      17                 :            : #include <boost/test/unit_test.hpp>
      18                 :            : 
      19                 :            : #include <ssrc/wispers/utility/DynamicLibrary.h>
      20                 :            : 
      21                 :            : using namespace NS_SSRC_WSPR_UTILITY;
      22                 :            : 
      23                 :            : extern "C" typedef int fun_type();
      24                 :            : extern "C" typedef fun_type* fun_ptr;
      25                 :            : 
      26   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(test_symbol) {
      27   [ +  -  +  -  :          2 :   DynamicLibrary library("dltest.so");
                   +  - ]
      28                 :            : 
      29   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(library.filename(), "dltest.so");
          +  -  +  -  +  
          -  +  -  +  -  
                   -  + ]
      30                 :            : 
      31   [ +  -  +  -  :          1 :   fun_ptr run_test = library.symbol<fun_ptr>("test42");
                   +  - ]
      32                 :            : 
      33   [ +  -  +  -  :          1 :   BOOST_CHECK(run_test != 0);
          +  -  +  -  +  
          -  +  -  +  -  
                   -  + ]
      34   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(run_test(), 42);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      35   [ +  -  +  - ]:          4 : }