Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - tests/wispers/utility - StringToTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 16 16 100.0 %
Date: 2012-04-09 Functions: 6 6 100.0 %
Branches: 53 106 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/StringTo.h>
      17                 :            : 
      18                 :            : #define BOOST_TEST_MODULE StringToTest
      19                 :            : #include <boost/test/unit_test.hpp>
      20                 :            : 
      21                 :            : using namespace NS_SSRC_WSPR_UTILITY;
      22                 :            : 
      23   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(test_number_cast) {
      24                 :          2 :   StringTo number_cast;
      25                 :            : 
      26   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(number_cast.cast<int>("183829"), 183829);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      27   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(number_cast.cast<int>("-48174"), -48174);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      28   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(number_cast.cast<float>("3.1415926"), 3.1415926f);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      29   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(number_cast.cast<bool>("1"), true);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      30   [ +  -  +  -  :          1 :   BOOST_CHECK_EQUAL(number_cast.cast<bool>("0"), false);
          +  -  +  -  +  
             -  +  -  -  
                      + ]
      31                 :          1 : }
      32                 :            : 
      33   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(test_string_to) {
      34   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<int>("183829"), 183829);
      35   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<int>("-48174"), -48174);
      36   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<float>("3.1415926"), 3.1415926f);
      37   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<float>("3.1415926"), 3.1415926f);
      38   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<bool>("1"), true);
      39   [ +  -  -  + ]:          1 :   BOOST_CHECK_EQUAL(string_to<bool>("0"), false);
      40   [ +  -  +  - ]:          4 : }