File: BmpOS2FileTest.cc

package info (click to toggle)
steghide 0.5.1-15
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,440 kB
  • sloc: cpp: 13,302; ansic: 6,184; sh: 3,960; makefile: 384; yacc: 316; perl: 228; sed: 16
file content (126 lines) | stat: -rw-r--r-- 4,879 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * steghide 0.5.1 - a steganography program
 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#include <iostream>

#include "BmpPaletteSampleValue.h"
#include "BmpRGBSampleValue.h"

#include "utcommon.h"
#include "BmpOS2FileTest.h"

BmpOS2FileTest::BmpOS2FileTest (TestSuite* s)
	: CvrStgFileTest("BmpOS2File", s)
{
	ADDTESTCATEGORY (BmpOS2FileTest, testReadWrite) ;
	ADDTESTCATEGORY (BmpOS2FileTest, testReadEmbedExtract) ;
	ADDTESTCATEGORY (BmpOS2FileTest, testReadEmbedWriteReadExtract) ;
	ADDTESTCATEGORY (BmpOS2FileTest, testPosition) ;
	ADDTESTCATEGORY (BmpOS2FileTest, testEmbeddedValue) ;
}

void BmpOS2FileTest::setup ()
{
	UnitTest::setup() ;

	Globs.reset() ;
	bs1 = new BitString (std::string ("a test")) ;
	f1 = CvrStgFile::readFile (std::string(DATADIR) + "os21x1_std.bmp") ;
	gl1 = Globs ;

	Globs.reset() ;
	bs2 = new BitString (std::string ("another test - this time a little longer")) ;
	f2 = CvrStgFile::readFile (std::string(DATADIR) + "os21x4_std.bmp") ;
	gl2 = Globs ;

	Globs.reset() ;
	bs3 = new BitString (std::string ("yet another test")) ;
	f3 = CvrStgFile::readFile (std::string(DATADIR) + "os21x8_std.bmp") ;
	gl3 = Globs ;

	Globs.reset() ;
	bs4 = new BitString (std::string ("last test")) ;
	f4 = CvrStgFile::readFile (std::string(DATADIR) + "os21x24_std.bmp") ;
	gl4 = Globs ;
}

void BmpOS2FileTest::cleanup ()
{
	UnitTest::cleanup() ;

	delete bs1 ; delete bs2 ; delete bs3 ; delete bs4 ;
	delete f1 ; delete f2 ; delete f3 ; delete f4 ;
}

void BmpOS2FileTest::testReadWrite (void)
{
	Globs = gl1 ; addTestResult(genericTestReadWrite(std::string(DATADIR) + "os21x1_std.bmp")) ;
	Globs = gl2 ; addTestResult(genericTestReadWrite(std::string(DATADIR) + "os21x4_std.bmp")) ;
	Globs = gl3 ; addTestResult(genericTestReadWrite(std::string(DATADIR) + "os21x8_std.bmp")) ;
	Globs = gl4 ; addTestResult(genericTestReadWrite(std::string(DATADIR) + "os21x24_std.bmp")) ;
}

void BmpOS2FileTest::testReadEmbedExtract (void)
{
	Globs = gl1 ; addTestResult(genericTestReadEmbedExtract(std::string(DATADIR) + "os21x1_std.bmp", *bs1)) ;
	Globs = gl2 ; addTestResult(genericTestReadEmbedExtract(std::string(DATADIR) + "os21x4_std.bmp", *bs2)) ;
	Globs = gl3 ; addTestResult(genericTestReadEmbedExtract(std::string(DATADIR) + "os21x8_std.bmp", *bs3)) ;
	Globs = gl4 ; addTestResult(genericTestReadEmbedExtract(std::string(DATADIR) + "os21x24_std.bmp", *bs4)) ;
}

void BmpOS2FileTest::testReadEmbedWriteReadExtract (void)
{
	Globs = gl1 ; addTestResult(genericTestReadEmbedWriteReadExtract(std::string(DATADIR) + "os21x1_std.bmp", *bs2)) ;
	Globs = gl2 ; addTestResult(genericTestReadEmbedWriteReadExtract(std::string(DATADIR) + "os21x4_std.bmp", *bs3)) ;
	Globs = gl3 ; addTestResult(genericTestReadEmbedWriteReadExtract(std::string(DATADIR) + "os21x8_std.bmp", *bs4)) ;
	Globs = gl4 ; addTestResult(genericTestReadEmbedWriteReadExtract(std::string(DATADIR) + "os21x24_std.bmp", *bs1)) ;
}

void BmpOS2FileTest::testPosition()
{
	Globs = gl1 ;
	addTestResult (genericTestPosition (f1, 0, new BmpPaletteSampleValue (1))) ;
	addTestResult (genericTestPosition (f1, 1, new BmpPaletteSampleValue (1))) ;
	addTestResult (genericTestPosition (f1, 2, new BmpPaletteSampleValue (1))) ;
	addTestResult (genericTestPosition (f1, 50, new BmpPaletteSampleValue (0))) ;
	addTestResult (genericTestPosition (f1, 2300, new BmpPaletteSampleValue (0))) ;
	addTestResult (genericTestPosition (f1, 2303, new BmpPaletteSampleValue (1))) ;

	Globs = gl2 ;
	addTestResult (genericTestPosition (f2, 0, new BmpPaletteSampleValue (7))) ;
	addTestResult (genericTestPosition (f2, 10, new BmpPaletteSampleValue (5))) ;
	addTestResult (genericTestPosition (f2, 95, new BmpPaletteSampleValue (1))) ;
	addTestResult (genericTestPosition (f2, 96, new BmpPaletteSampleValue (8))) ;

	// TODO
}

void BmpOS2FileTest::testReadExtractCompare ()
{
	// TODO
}

void BmpOS2FileTest::testEmbeddedValue ()
{
	Globs = gl1 ; addTestResult (genericTestEmbeddedValue (f1)) ;
	Globs = gl2 ; addTestResult (genericTestEmbeddedValue (f2)) ;
	Globs = gl3 ; addTestResult (genericTestEmbeddedValue (f3)) ;
	Globs = gl4 ; addTestResult (genericTestEmbeddedValue (f4)) ;
}