LCOV - code coverage report
Current view: top level - testsuite - RelationTest.cc (source / functions) Hit Total Coverage
Test: STX B+ Tree Testsuite Lines: 27 27 100.0 %
Date: 2013-05-05 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * STX B+ Tree Test Suite v0.9
       3             :  * Copyright (C) 2008-2013 Timo Bingmann
       4             :  *
       5             :  * This program is free software: you can redistribute it and/or modify it
       6             :  * under the terms of the GNU General Public License as published by the Free
       7             :  * Software Foundation, either version 3 of the License, or (at your option)
       8             :  * any later version.
       9             :  *
      10             :  * This program is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
      13             :  * more details.
      14             :  *
      15             :  * You should have received a copy of the GNU General Public License along with
      16             :  * this program. If not, see <http://www.gnu.org/licenses/>.
      17             :  */
      18             : 
      19             : #include "tpunit.h"
      20             : 
      21             : #include <stdlib.h>
      22             : 
      23             : #include <stx/btree_multiset.h>
      24             : 
      25             : struct RelationTest : public tpunit::TestFixture
      26             : {
      27           1 :     RelationTest() : tpunit::TestFixture(
      28             :         TEST(RelationTest::test_relations)
      29           1 :         )
      30           1 :     {}
      31             : 
      32             :     template <typename KeyType>
      33             :     struct traits_nodebug : stx::btree_default_set_traits<KeyType>
      34             :     {
      35             :         static const bool       selfverify = true;
      36             :         static const bool       debug = false;
      37             : 
      38             :         static const int        leafslots = 8;
      39             :         static const int        innerslots = 8;
      40             :     };
      41             : 
      42           1 :     void test_relations()
      43             :     {
      44             :         typedef stx::btree_multiset<unsigned int,
      45             :             std::less<unsigned int>, traits_nodebug<unsigned int> > btree_type;
      46             : 
      47           1 :         btree_type bt1, bt2;
      48             : 
      49           1 :         srand(34234236);
      50         321 :         for(unsigned int i = 0; i < 320; i++)
      51             :         {
      52         320 :             unsigned int key = rand() % 1000;
      53             : 
      54         320 :             bt1.insert(key);
      55         320 :             bt2.insert(key);
      56             :         }
      57             : 
      58           1 :         ASSERT( bt1 == bt2 );
      59             : 
      60           1 :         bt1.insert(499);
      61           1 :         bt2.insert(500);
      62             : 
      63           1 :         ASSERT( bt1 != bt2 );
      64           1 :         ASSERT( bt1 < bt2 );
      65           1 :         ASSERT( !(bt1 > bt2) );
      66             : 
      67           1 :         bt1.insert(500);
      68           1 :         bt2.insert(499);
      69             : 
      70           1 :         ASSERT( bt1 == bt2 );
      71           1 :         ASSERT( bt1 <= bt2 );
      72             : 
      73             :         // test assignment operator
      74           1 :         btree_type bt3;
      75             : 
      76           1 :         bt3 = bt1;
      77           1 :         ASSERT( bt1 == bt3 );
      78           1 :         ASSERT( bt1 >= bt3 );
      79             : 
      80             :         // test copy constructor
      81           1 :         btree_type bt4 = bt3;
      82             : 
      83           1 :         ASSERT( bt1 == bt4 );
      84             :     }
      85             : 
      86           3 : } __RelationTest;

Generated by: LCOV version 1.10