LCOV - code coverage report
Current view: directory - testsuite - test_instantiate.cc (source / functions) Found Hit Coverage
Test: STX CBTreeDB Testsuite Lines: 5 3 60.0 %
Date: 2010-04-14 Functions: 8 3 37.5 %

       1                 : // -*- mode: c++; fill-column: 79 -*-
       2                 : // $Id: test_instantiate.cc 6 2010-04-14 11:05:51Z tb $
       3                 : 
       4                 : /*
       5                 :  * STX Constant B-Tree Database Template Classes v0.7.0
       6                 :  * Copyright (C) 2010 Timo Bingmann
       7                 :  *
       8                 :  * This library is free software; you can redistribute it and/or modify it
       9                 :  * under the terms of the GNU Lesser General Public License as published by the
      10                 :  * Free Software Foundation; either version 2.1 of the License, or (at your
      11                 :  * option) any later version.
      12                 :  *
      13                 :  * This library is distributed in the hope that it will be useful, but WITHOUT
      14                 :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15                 :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
      16                 :  * for more details.
      17                 :  *
      18                 :  * You should have received a copy of the GNU Lesser General Public License
      19                 :  * along with this library; if not, write to the Free Software Foundation,
      20                 :  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      21                 :  */
      22                 : 
      23                 : /*
      24                 :  * Force instantiation of different class configurations to test
      25                 :  * compilation of all functions with different template
      26                 :  * parameters. Also tests class with a struct as key_type.
      27                 :  */
      28                 : 
      29                 : #define CBTREEDB_SELF_VERIFY
      30                 : #include "stx-cbtreedb.h"
      31                 : 
      32                 : #include <iostream>
      33                 : #include <sstream>
      34                 : #include <assert.h>
      35                 : 
      36                 : // forced instantiations
      37                 : 
      38                 : template class stx::CBTreeDB<>;
      39                 : 
      40                 : template class stx::CBTreeDB< uint32_t, std::greater<uint32_t> >;
      41                 : 
      42                 : template class stx::CBTreeDB< uint64_t, std::greater<uint64_t> >;
      43                 : 
      44                 : struct key_struct
      45                 : {
      46                 :     uint8_t     i8;
      47                 :     uint32_t    i32;
      48                 : }       
      49                 :     __attribute__((packed));
      50                 : 
      51                 : struct key_struct_less
      52                 : {
      53               0 :     inline bool operator()(const key_struct& a, const key_struct& b)
      54                 :     {
      55               0 :         return a.i8 < b.i8;
      56                 :     }
      57                 : };
      58                 : 
      59                 : template class stx::CBTreeDB< key_struct, key_struct_less >;
      60                 : 
      61               1 : int main()
      62                 : {
      63                 :     // check some instance parameters
      64                 :     {
      65                 :         typedef stx::CBTreeDB<> cbtreedb;
      66                 : 
      67                 :         assert(cbtreedb::BTreePageSize == 1024);
      68                 :         //assert(sizeof(cbtreedb::LeafNode) == 1024);
      69                 :         assert(cbtreedb::LeafNodeNumKeys == 126);
      70                 :         assert(cbtreedb::LeafNodeFiller == 0);
      71                 :         assert(cbtreedb::InnerNodeNumKeys == 254);
      72                 :         assert(cbtreedb::InnerNodeFiller == 0);
      73                 :     }
      74                 :     {
      75                 :         typedef stx::CBTreeDB<uint64_t> cbtreedb;
      76                 : 
      77                 :         assert(cbtreedb::BTreePageSize == 1024);
      78                 :         //assert(sizeof(cbtreedb::LeafNode) == 1024);
      79                 :         assert(cbtreedb::LeafNodeNumKeys == 84);
      80                 :         assert(cbtreedb::LeafNodeFiller == 0);
      81                 :         assert(cbtreedb::InnerNodeNumKeys == 127);
      82                 :         assert(cbtreedb::InnerNodeFiller == 0);
      83                 :     }
      84                 :     {
      85                 :         typedef stx::CBTreeDB<uint64_t, std::less<uint64_t>, 2048> cbtreedb;
      86                 : 
      87                 :         assert(cbtreedb::BTreePageSize == 2048);
      88                 :         //assert(sizeof(cbtreedb::LeafNode) == 2048);
      89                 :         assert(cbtreedb::LeafNodeNumKeys == 169);
      90                 :         assert(cbtreedb::LeafNodeFiller == 4);
      91                 :         assert(cbtreedb::InnerNodeNumKeys == 255);
      92                 :         assert(cbtreedb::InnerNodeFiller == 0);
      93                 :     }
      94                 : 
      95               1 :     return 0;
      96               3 : }

Generated by: LCOV version 1.7