wpkg test coverage results

Coverage test results of the Windows Packager by Made to Order Software Corporation.

LCOV - code coverage report
Current view: top level - tests/unittests - unittest_memfile.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 53 53 100.0 %
Date: 2013-06-17 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*    unittest_memfile.cpp
       2             :  *    Copyright (C) 2013  Made to Order Software Corporation
       3             :  *
       4             :  *    This program is free software; you can redistribute it and/or modify
       5             :  *    it under the terms of the GNU General Public License as published by
       6             :  *    the Free Software Foundation; either version 2 of the License, or
       7             :  *    (at your option) any later version.
       8             :  *
       9             :  *    This program is distributed in the hope that it will be useful,
      10             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *    GNU General Public License for more details.
      13             :  *
      14             :  *    You should have received a copy of the GNU General Public License along
      15             :  *    with this program; if not, write to the Free Software Foundation, Inc.,
      16             :  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  *
      18             :  *    Authors
      19             :  *    Alexis Wilke   alexis@m2osw.com
      20             :  */
      21             : 
      22             : #include "unittest_memfile.h"
      23             : #include "libdebpackages/memfile.h"
      24             : 
      25             : #include <cppunit/config/SourcePrefix.h>
      26             : #include <string.h>
      27             : #include <time.h>
      28             : 
      29             : 
      30             : // seed: 1367790804
      31             : 
      32           1 : CPPUNIT_TEST_SUITE_REGISTRATION( MemfileUnitTests );
      33             : 
      34           9 : void MemfileUnitTests::setUp()
      35             : {
      36           9 : }
      37             : 
      38             : 
      39           9 : void MemfileUnitTests::compression(int zlevel)
      40             : {
      41           9 :     memfile::memory_file i;         // input
      42           9 :     memfile::memory_file z;         // compressed
      43           9 :     memfile::memory_file t;         // test version (must be == to input)
      44             : 
      45             :     // Test 1
      46             :     // create a file of 0 to block_size bytes with all z levels
      47           9 :     const int block_size = 145 * 1024;
      48             :     char buf[block_size + 1];
      49             :     char tst[block_size + 1];
      50     1336329 :     for(int pos = 0; pos < block_size; ++pos)
      51             :     {
      52     1336320 :         buf[pos] = rand();
      53             :     }
      54             : 
      55           9 :     i.create(memfile::memory_file::file_format_other);
      56        2617 :     for(int size = 0; size <= block_size; size += rand() & 0x03FF)
      57             :     {
      58        2608 :         CPPUNIT_ASSERT( i.write(buf, 0, size) == size );
      59        2608 :         i.compress(z, memfile::memory_file::file_format_gz, zlevel);
      60        2608 :         z.decompress(t);
      61        2608 :         memset(tst, 0, size);
      62        2608 :         CPPUNIT_ASSERT( t.read(tst, 0, size) == size );
      63        2608 :         CPPUNIT_ASSERT( memcmp(buf, tst, size) == 0 );
      64             : 
      65        2608 :         CPPUNIT_ASSERT( i.write(buf, 0, size) == size );
      66             : //fprintf(stderr, "Try bz2 compression\n");
      67             : //i.write_file("last-file.raw");
      68        2608 :         i.compress(z, memfile::memory_file::file_format_bz2, zlevel);
      69             : //fprintf(stderr, "Succeeded bz2 compression, expected size = %d\n", size);
      70        2608 :         z.decompress(t);
      71        2608 :         memset(tst, 0, size);
      72        2608 :         CPPUNIT_ASSERT( t.read(tst, 0, size) == size );
      73        2608 :         CPPUNIT_ASSERT( memcmp(buf, tst, size) == 0 );
      74           9 :     }
      75           9 : }
      76             : 
      77           1 : void MemfileUnitTests::compression1()
      78             : {
      79           1 :     compression(1);
      80           1 : }
      81             : 
      82           1 : void MemfileUnitTests::compression2()
      83             : {
      84           1 :     compression(2);
      85           1 : }
      86             : 
      87           1 : void MemfileUnitTests::compression3()
      88             : {
      89           1 :     compression(3);
      90           1 : }
      91             : 
      92           1 : void MemfileUnitTests::compression4()
      93             : {
      94           1 :     compression(4);
      95           1 : }
      96             : 
      97           1 : void MemfileUnitTests::compression5()
      98             : {
      99           1 :     compression(5);
     100           1 : }
     101             : 
     102           1 : void MemfileUnitTests::compression6()
     103             : {
     104           1 :     compression(6);
     105           1 : }
     106             : 
     107           1 : void MemfileUnitTests::compression7()
     108             : {
     109           1 :     compression(7);
     110           1 : }
     111             : 
     112           1 : void MemfileUnitTests::compression8()
     113             : {
     114           1 :     compression(8);
     115           1 : }
     116             : 
     117           1 : void MemfileUnitTests::compression9()
     118             : {
     119           1 :     compression(9);
     120           4 : }
     121             : 
     122             : 
     123             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.9

The wpkg tool is an open source tool created by Made to Order Software Corporation.