Web Wispers 1.2.1 C++ Unit Test Coverage
Current view: top level - tests/wispers/utility - UUIDGeneratorTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.1 C++ Unit Tests Lines: 14 14 100.0 %
Date: 2011-11-11 Functions: 11 12 91.7 %
Branches: 49 100 49.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 2010 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/utility/UUIDGenerator.h>
      19                 :            : #include <ssrc/wispers/utility/uuid_key.h>
      20                 :            : #include <ssrc/wispers/utility/ToString.h>
      21                 :            : 
      22                 :            : #include <boost/uuid/uuid_io.hpp>
      23                 :            : 
      24                 :            : using namespace NS_SSRC_WSPR_UTILITY;
      25                 :            : 
      26         [ -  + ]:          3 : struct UUIDGeneratorTest : public TestCase {
      27                 :            : 
      28                 :          1 :   void test_uuid_to_uuid_key() {
      29                 :          2 :     UUIDGenerator uuid_gen;
      30                 :            :       boost::uuids::string_generator uuid_str_gen;
      31                 :            : 
      32         [ +  + ]:        101 :     for(unsigned int i = 0; i < 100; ++i) {
      33         [ +  - ]:        100 :       boost::uuids::uuid uuid = uuid_gen.gen_uuid();
      34         [ +  - ]:        100 :       uuid_key_type uuid_key = uuid_to_uuid_key(uuid);
      35   [ +  -  +  -  :        100 :       boost::uuids::uuid uuid2 = uuid_str_gen(to_string(uuid_key));
                   +  - ]
      36   [ +  -  +  -  :        100 :       CPPUNIT_ASSERT(uuid == uuid2);
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
             -  +  -  +  
                      - ]
      37                 :            :     }
      38                 :          1 :   }
      39                 :            : 
      40   [ +  -  +  -  :          4 :   CPPUNIT_TEST_SUITE(UUIDGeneratorTest);
             +  -  #  # ]
      41   [ +  -  +  -  :          1 :   CPPUNIT_TEST(test_uuid_to_uuid_key);
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
      42   [ +  -  +  -  :          2 :   CPPUNIT_TEST_SUITE_END();
          +  -  +  -  +  
                -  +  - ]
      43                 :            : };
      44                 :            : 
      45   [ -  +  #  # ]:          1 : CPPUNIT_TEST_SUITE_REGISTRATION(UUIDGeneratorTest);
      46   [ +  -  +  -  :          4 : WISP_TEST_MAIN()
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                -  +  - ]