Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - tests/wispers/utility - ToStringTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 19 19 100.0 %
Date: 2012-04-09 Functions: 6 6 100.0 %
Branches: 63 126 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* Copyright 2006-2011 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/utility/ToString.h>
      17                 :            : 
      18                 :            : #define BOOST_TEST_MODULE ToStringTest
      19                 :            : #include <boost/test/unit_test.hpp>
      20                 :            : 
      21                 :            : using namespace NS_SSRC_WSPR_UTILITY;
      22                 :            : 
      23   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(test_string_cast) {
      24                 :          2 :   ToString string_cast;
      25                 :          1 :   unsigned int foo = 81919;
      26   [ +  -  +  -  :          2 :   string foo_str = string_cast(foo);
                   +  - ]
      27                 :            : 
      28   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(foo_str, "81919");
          +  -  +  -  +  
                -  -  + ]
      29   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(string_cast(358), "358");
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      30   [ +  -  +  -  :          1 :   BOOST_CHECK(!std::strcmp("1776", string_cast.c_str(1776)));
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  -  + ]
      31                 :            : 
      32   [ +  -  +  - ]:          2 :   const string long_str("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
      33   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(string_cast(long_str), long_str);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      34                 :            : 
      35         [ +  - ]:          1 :   string_cast.setf(std::ios::hex, std::ios::basefield);
      36         [ +  - ]:          1 :   string_cast.setf(std::ios::uppercase);
      37                 :            : 
      38   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(string_cast(15), "F");
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      39                 :          1 : }
      40                 :            : 
      41   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(test_to_string) {
      42                 :          1 :   unsigned int foo = 81919;
      43                 :          2 :   string foo_str = to_string(foo);
      44                 :            : 
      45   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(foo_str, "81919");
          +  -  +  -  +  
                -  -  + ]
      46   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(to_string(358), "358");
          +  -  +  -  +  
          -  +  -  +  -  
                   -  + ]
      47   [ +  -  +  - ]:          4 : }