LCOV - code coverage report
Current view: directory - testsuite - test_crc32.cc (source / functions) Found Hit Coverage
Test: STX CBTreeDB Testsuite Lines: 9 9 100.0 %
Date: 2010-04-14 Functions: 4 4 100.0 %

       1                 : // -*- mode: c++; fill-column: 79 -*-
       2                 : // $Id: test_crc32.cc 2 2010-04-14 07:34:58Z 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                 :  * Test CRC32 class by calculating and comparing a few checksums.
      25                 :  */
      26                 : 
      27                 : #define CBTREEDB_SELF_VERIFY
      28                 : #include "stx-cbtreedb.h"
      29                 : 
      30                 : #include <assert.h>
      31                 : 
      32                 : // simple method to access the protected CRC32 class
      33                 : class CBTreeDBTest : public stx::CBTreeDB<>
      34                 : {
      35                 : public:
      36                 : 
      37               4 :     static uint32_t CRC32_digest(const std::string& str)
      38                 :     {
      39               4 :         return CRC32::digest(str);
      40                 :     }
      41                 : };
      42                 : 
      43               1 : int main()
      44                 : {
      45               1 :     assert( CBTreeDBTest::CRC32_digest("") == 0x00000000 );
      46                 : 
      47               2 :     assert( CBTreeDBTest::CRC32_digest("test string") == 0x13471545 );
      48                 : 
      49               2 :     assert( CBTreeDBTest::CRC32_digest("0123456789012345678901234567890123456789") == 0xA6463C49 );
      50                 : 
      51               2 :     assert( CBTreeDBTest::CRC32_digest("wYHemLvD4RCdRZJc0ac42WAL1SIjaRdd8OxLeAjtOc") == 0x1CFCEA07 );
      52                 : 
      53               1 :     return 0;
      54               3 : }

Generated by: LCOV version 1.7