LTP GCOV extension - code coverage report
Current view: directory - testsuite - RelationTest.cc
Test: STX B+ Tree Testsuite
Date: 2007-05-08 Instrumented lines: 31
Code covered: 96.8 % Executed lines: 30

       1                 : // $Id: RelationTest.cc 35 2007-04-27 11:26:33Z tb $
       2                 : 
       3                 : /*
       4                 :  * STX B+ Tree Template Classes v0.7
       5                 :  * Copyright (C) 2007 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               3 :     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               2 :         CPPUNIT_ASSERT( bt1 < bt2 );
      68               2 :         CPPUNIT_ASSERT( !(bt1 > bt2) );
      69                 : 
      70               1 :         bt1.insert(500);
      71               1 :         bt2.insert(499);
      72                 : 
      73               1 :         CPPUNIT_ASSERT( bt1 == bt2 );
      74               2 :         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               2 :         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               0 : 
      90               3 : CPPUNIT_TEST_SUITE_REGISTRATION( RelationTest );

Generated by: LTP GCOV extension version 1.4