1 /*
2 * steghide 0.5.1 - a steganography program
3 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21 #include <iostream>
22
23 #include "utcommon.h"
24 #include "BmpWinFileTest.h"
25
26 #include "BmpPaletteSampleValue.h"
27 #include "BmpRGBSampleValue.h"
28
BmpWinFileTest(TestSuite * s)29 BmpWinFileTest::BmpWinFileTest (TestSuite* s)
30 : CvrStgFileTest("BmpWinFile", s)
31 {
32 ADDTESTCATEGORY (BmpWinFileTest, testReadWrite) ;
33 ADDTESTCATEGORY (BmpWinFileTest, testReadEmbedExtract) ;
34 ADDTESTCATEGORY (BmpWinFileTest, testReadEmbedWriteReadExtract) ;
35 ADDTESTCATEGORY (BmpWinFileTest, testPosition) ;
36 ADDTESTCATEGORY (BmpWinFileTest, testEmbeddedValue) ;
37 }
38
setup()39 void BmpWinFileTest::setup ()
40 {
41 UnitTest::setup() ;
42
43 Globs.reset() ;
44 f1 = CvrStgFile::readFile (std::string(DATADIR) + "win3x1_std.bmp") ;
45 bs1 = new BitString (std::string ("this is a test")) ;
46 gl1 = Globs ;
47
48 Globs.reset() ;
49 f2 = CvrStgFile::readFile (std::string(DATADIR) + "win3x4_std.bmp") ;
50 bs2 = new BitString (std::string ("this is another test - this time a little longer")) ;
51 gl2 = Globs ;
52
53 Globs.reset() ;
54 f3 = CvrStgFile::readFile (std::string(DATADIR) + "win3x8_std.bmp") ;
55 bs3 = new BitString (std::string ("yet another test which is even longer than the previous test bitstring")) ;
56 gl3 = Globs ;
57
58 Globs.reset() ;
59 f4 = CvrStgFile::readFile (std::string(DATADIR) + "win3x24_std.bmp") ;
60 bs4 = new BitString (std::string ("the last test")) ;
61 gl4 = Globs ;
62 }
63
cleanup()64 void BmpWinFileTest::cleanup ()
65 {
66 UnitTest::cleanup() ;
67
68 delete bs1 ; delete bs2 ; delete bs3 ; delete bs4 ;
69 delete f1 ; delete f2 ; delete f3 ; delete f4 ;
70 }
71
testReadWrite()72 void BmpWinFileTest::testReadWrite()
73 {
74 Globs = gl1 ; addTestResult (genericTestReadWrite (std::string(DATADIR) + "win3x1_std.bmp")) ;
75 Globs = gl2 ; addTestResult (genericTestReadWrite (std::string(DATADIR) + "win3x4_std.bmp")) ;
76 Globs = gl3 ; addTestResult (genericTestReadWrite (std::string(DATADIR) + "win3x8_std.bmp")) ;
77 Globs = gl4 ; addTestResult (genericTestReadWrite (std::string(DATADIR) + "win3x24_std.bmp")) ;
78 }
79
testReadEmbedExtract()80 void BmpWinFileTest::testReadEmbedExtract()
81 {
82 Globs = gl1 ; addTestResult (genericTestReadEmbedExtract (std::string(DATADIR) + "win3x1_std.bmp", *bs1)) ;
83 Globs = gl2 ; addTestResult (genericTestReadEmbedExtract (std::string(DATADIR) + "win3x4_std.bmp", *bs2)) ;
84 Globs = gl3 ; addTestResult (genericTestReadEmbedExtract (std::string(DATADIR) + "win3x8_std.bmp", *bs3)) ;
85 Globs = gl4 ; addTestResult (genericTestReadEmbedExtract (std::string(DATADIR) + "win3x24_std.bmp", *bs4)) ;
86 }
87
testReadEmbedWriteReadExtract()88 void BmpWinFileTest::testReadEmbedWriteReadExtract()
89 {
90 Globs = gl1 ; addTestResult (genericTestReadEmbedWriteReadExtract (std::string(DATADIR) + "win3x1_std.bmp", *bs2)) ;
91 Globs = gl2 ; addTestResult (genericTestReadEmbedWriteReadExtract (std::string(DATADIR) + "win3x4_std.bmp", *bs3)) ;
92 Globs = gl3 ; addTestResult (genericTestReadEmbedWriteReadExtract (std::string(DATADIR) + "win3x8_std.bmp", *bs4)) ;
93 Globs = gl4 ; addTestResult (genericTestReadEmbedWriteReadExtract (std::string(DATADIR) + "win3x24_std.bmp", *bs1)) ;
94 }
95
testPosition()96 void BmpWinFileTest::testPosition()
97 {
98 Globs = gl1 ;
99 addTestResult (genericTestPosition (f1, 0, new BmpPaletteSampleValue (0))) ;
100 addTestResult (genericTestPosition (f1, 1, new BmpPaletteSampleValue (1))) ;
101 addTestResult (genericTestPosition (f1, 143, new BmpPaletteSampleValue (1))) ;
102 addTestResult (genericTestPosition (f1, 144, new BmpPaletteSampleValue (0))) ;
103 addTestResult (genericTestPosition (f1, 2303, new BmpPaletteSampleValue (1))) ;
104 addTestResult (genericTestPosition (f1, 2302, new BmpPaletteSampleValue (0))) ;
105
106 Globs = gl2 ;
107 addTestResult (genericTestPosition (f2, 0, new BmpPaletteSampleValue (9))) ;
108 addTestResult (genericTestPosition (f2, 20, new BmpPaletteSampleValue (4))) ;
109 addTestResult (genericTestPosition (f2, 47, new BmpPaletteSampleValue (13))) ;
110 addTestResult (genericTestPosition (f2, 48, new BmpPaletteSampleValue (9))) ;
111 addTestResult (genericTestPosition (f2, 2303, new BmpPaletteSampleValue (3))) ;
112
113 Globs = gl3 ;
114 addTestResult (genericTestPosition (f3, 0, new BmpPaletteSampleValue (202))) ;
115 addTestResult (genericTestPosition (f3, 4, new BmpPaletteSampleValue (38))) ;
116 addTestResult (genericTestPosition (f3, 47, new BmpPaletteSampleValue (81))) ;
117 addTestResult (genericTestPosition (f3, 48, new BmpPaletteSampleValue (66))) ;
118 addTestResult (genericTestPosition (f3, 2302, new BmpPaletteSampleValue (105))) ;
119
120 Globs = gl4 ;
121 addTestResult (genericTestPosition (f4, 0, new BmpRGBSampleValue (121, 110, 119))) ;
122 addTestResult (genericTestPosition (f4, 1, new BmpRGBSampleValue (113, 109, 130))) ;
123 addTestResult (genericTestPosition (f4, 12, new BmpRGBSampleValue (92, 113, 115))) ;
124 addTestResult (genericTestPosition (f4, 2303, new BmpRGBSampleValue (75, 107, 158))) ;
125 }
126
testReadExtractCompare()127 void BmpWinFileTest::testReadExtractCompare()
128 {
129 // TODO
130 }
131
testEmbeddedValue()132 void BmpWinFileTest::testEmbeddedValue ()
133 {
134 Globs = gl1 ; addTestResult (genericTestEmbeddedValue (f1)) ;
135 Globs = gl2 ; addTestResult (genericTestEmbeddedValue (f2)) ;
136 Globs = gl3 ; addTestResult (genericTestEmbeddedValue (f3)) ;
137 Globs = gl4 ; addTestResult (genericTestEmbeddedValue (f4)) ;
138 }
139