Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - tests/wispers/utility - UUIDGeneratorTest.cc (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 8 8 100.0 %
Date: 2012-04-09 Functions: 4 4 100.0 %
Branches: 20 38 52.6 %

           Branch data     Line data    Source code
       1                 :            : /* Copyright 2010 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/UUIDGenerator.h>
      17                 :            : #include <ssrc/wispers/utility/uuid_key.h>
      18                 :            : #include <ssrc/wispers/utility/ToString.h>
      19                 :            : 
      20                 :            : #include <boost/uuid/uuid_io.hpp>
      21                 :            : 
      22                 :            : #define BOOST_TEST_MODULE UUIDGeneratorTest
      23                 :            : #include <boost/test/unit_test.hpp>
      24                 :            : 
      25                 :            : using namespace NS_SSRC_WSPR_UTILITY;
      26                 :            : using NS_SSRC_WSPR::uuid_key_type;
      27                 :            : 
      28   [ +  -  +  - ]:          3 : BOOST_AUTO_TEST_CASE(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 :     BOOST_CHECK(uuid == uuid2);
          +  -  +  -  +  
          -  +  -  +  -  
             +  -  -  + ]
      37                 :            :   }
      38   [ +  -  +  - ]:          4 : }