LCOV - code coverage report
Current view: directory - testsuite - test_sha256.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_sha256.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 SHA256 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 SHA256 class
      33                 : class CBTreeDBTest : public stx::CBTreeDB<>
      34                 : {
      35                 : public:
      36                 : 
      37               4 :     static std::string SHA256_digest_hex(const std::string& str)
      38                 :     {
      39               4 :         return SHA256::digest_hex(str);
      40                 :     }
      41                 : };
      42                 : 
      43               1 : int main()
      44                 : {
      45                 :     assert( CBTreeDBTest::SHA256_digest_hex("") ==
      46               1 :             "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855" );
      47                 : 
      48                 :     assert( CBTreeDBTest::SHA256_digest_hex("test string") ==
      49               2 :             "D5579C46DFCC7F18207013E65B44E4CB4E2C2298F4AC457BA8F82743F31E930B" );
      50                 : 
      51                 :     assert( CBTreeDBTest::SHA256_digest_hex("0123456789012345678901234567890123456789") ==
      52               2 :             "FB526CD4AD0EC978C1A9E78F7C0728711139978424D618EB228BE59E21188970" );
      53                 : 
      54                 :     assert( CBTreeDBTest::SHA256_digest_hex("wYHemLvD4RCdRZJc0ac42WAL1SIjaRdd8OxLeAjtOc") ==
      55               2 :             "0466B66B8A7EDA7891B9394BC1BC2254BA450A850295CC62A43A695999A77DCD" );
      56                 : 
      57               1 :     return 0;
      58               3 : }

Generated by: LCOV version 1.7