LCOV - code coverage report
Current view: top level - testsuite - RelationTest.cc (source / functions) Hit Total Coverage
Test: STX B+ Tree Testsuite Lines: 29 29 100.0 %
Date: 2011-05-18 Functions: 8 9 88.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 16 43.8 %

           Branch data     Line data    Source code
       1                 :            : // $Id: RelationTest.cc 128 2011-05-18 07:23:35Z tb $
       2                 :            : 
       3                 :            : /*
       4                 :            :  * STX B+ Tree Template Classes v0.8.6
       5                 :            :  * Copyright (C) 2008-2011 Timo Bingmann
       6                 :            :  *
       7                 :            :  * This library is free software; you can redistribute it and/or modify it
       8                 :            :  * under the terms of the GNU Lesser General Public License as published by the
       9                 :            :  * Free Software Foundation; either version 2.1 of the License, or (at your
      10                 :            :  * option) any later version.
      11                 :            :  *
      12                 :            :  * This library is distributed in the hope that it will be useful, but WITHOUT
      13                 :            :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :            :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
      15                 :            :  * for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU Lesser General Public License
      18                 :            :  * along with this library; if not, write to the Free Software Foundation,
      19                 :            :  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #include <cppunit/extensions/HelperMacros.h>
      23                 :            : 
      24                 :            : #include <stdlib.h>
      25                 :            : 
      26                 :            : #include <stx/btree_multiset.h>
      27                 :            : 
      28                 :            : class RelationTest : public CPPUNIT_NS::TestFixture
      29 [ +  - ][ #  # ]:          2 : {
      30 [ +  - ][ +  - ]:          2 :     CPPUNIT_TEST_SUITE( RelationTest );
                 [ #  # ]
      31                 :          1 :     CPPUNIT_TEST(test_relations);
      32                 :          2 :     CPPUNIT_TEST_SUITE_END();
      33                 :            : 
      34                 :            : protected:
      35                 :            : 
      36                 :            :     struct traits_nodebug
      37                 :            :     {
      38                 :            :         static const bool       selfverify = true;
      39                 :            :         static const bool       debug = false;
      40                 :            : 
      41                 :            :         static const int        leafslots = 8;
      42                 :            :         static const int        innerslots = 8;
      43                 :            :     };
      44                 :            : 
      45                 :          1 :     void test_relations()
      46                 :            :     {
      47                 :            :         typedef stx::btree_multiset<unsigned int,
      48                 :            :             std::less<unsigned int>, struct traits_nodebug> btree_type;
      49                 :            : 
      50                 :          1 :         btree_type bt1, bt2;
      51                 :            : 
      52                 :          1 :         srand(34234236);
      53         [ +  + ]:        321 :         for(unsigned int i = 0; i < 320; i++)
      54                 :            :         {
      55                 :        320 :             unsigned int key = rand() % 1000;
      56                 :            : 
      57                 :        320 :             bt1.insert(key);
      58                 :        320 :             bt2.insert(key);
      59                 :            :         }
      60                 :            : 
      61                 :          1 :         CPPUNIT_ASSERT( bt1 == bt2 );
      62                 :            : 
      63                 :          1 :         bt1.insert(499);
      64                 :          1 :         bt2.insert(500);
      65                 :            : 
      66                 :          1 :         CPPUNIT_ASSERT( bt1 != bt2 );
      67                 :          1 :         CPPUNIT_ASSERT( bt1 < bt2 );
      68                 :          1 :         CPPUNIT_ASSERT( !(bt1 > bt2) );
      69                 :            : 
      70                 :          1 :         bt1.insert(500);
      71                 :          1 :         bt2.insert(499);
      72                 :            : 
      73                 :          1 :         CPPUNIT_ASSERT( bt1 == bt2 );
      74                 :          1 :         CPPUNIT_ASSERT( bt1 <= bt2 );
      75                 :            : 
      76                 :            :         // test assignment operator
      77                 :          1 :         btree_type bt3;
      78                 :            : 
      79                 :          1 :         bt3 = bt1;
      80                 :          1 :         CPPUNIT_ASSERT( bt1 == bt3 );
      81                 :          1 :         CPPUNIT_ASSERT( bt1 >= bt3 );
      82                 :            : 
      83                 :            :         // test copy constructor
      84                 :          1 :         btree_type bt4 = bt3;
      85                 :            : 
      86                 :          1 :         CPPUNIT_ASSERT( bt1 == bt4 );
      87                 :          1 :     }
      88                 :            : };
      89                 :            : 
      90 [ +  - ][ +  - ]:          3 : CPPUNIT_TEST_SUITE_REGISTRATION( RelationTest );

Generated by: LCOV version 1.9