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
|
/*
* 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 <vector>
#include "AuSampleValues.h"
#include "common.h"
#include "SampleValueAdjacencyListTest.h"
#include "utcommon.h"
SampleValueAdjacencyListTest::SampleValueAdjacencyListTest (TestSuite* s)
: UnitTest ("SampleValueAdjacencyList", s), DummySVAL (100)
{
ADDTESTCATEGORY (SampleValueAdjacencyListTest, testEquality) ;
ADDTESTCATEGORY (SampleValueAdjacencyListTest, testQuicksort) ;
}
void SampleValueAdjacencyListTest::setup ()
{
SVEmpty = std::vector<SampleValue*> (100) ;
}
void SampleValueAdjacencyListTest::testEquality ()
{
CvrStgFile *f = CvrStgFile::readFile (std::string(DATADIR) + "mulaw_std.au") ;
SampleValueAdjacencyList sval1 (2) ;
SampleValueAdjacencyList sval2 (2) ;
sval1[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (10)) ;
sval1[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (15)) ;
sval1[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (17)) ;
sval1[(SampleValueLabel) 1].push_back (new AuMuLawSampleValue (100)) ;
sval2[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (10)) ;
sval2[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (15)) ;
sval2[(SampleValueLabel) 0].push_back (new AuMuLawSampleValue (17)) ;
sval2[(SampleValueLabel) 1].push_back (new AuMuLawSampleValue (100)) ;
addTestResult (sval1 == sval2) ;
sval2[(SampleValueLabel) 1].push_back (new AuMuLawSampleValue (110)) ;
addTestResult (!(sval1 == sval2)) ;
delete f ;
}
void SampleValueAdjacencyListTest::testQuicksort ()
{
{
UWORD32* d = new UWORD32[2] ;
d[0] = 3 ;
d[1] = 5 ;
DummySVAL.quicksort (SVEmpty, d, 0, 1) ;
addTestResult ((d[0] == 3) && (d[1] == 5)) ;
delete[] d ;
}
{
UWORD32* d = new UWORD32[2] ;
d[0] = 5 ;
d[1] = 3 ;
DummySVAL.quicksort (SVEmpty, d, 0, 1) ;
addTestResult ((d[0] == 3) && (d[1] == 5)) ;
delete[] d ;
}
{
UWORD32* d = new UWORD32[3] ;
d[0] = 2 ;
d[1] = 2 ;
d[2] = 2 ;
DummySVAL.quicksort (SVEmpty, d, 0, 2) ;
addTestResult ((d[0] == 2) && (d[1] == 2) && (d[2] == 2)) ; // asserting termination
delete[] d ;
}
{
UWORD32* d = new UWORD32[10] ;
d[0] = 3 ; d[1] = 12 ; d[2] = 8 ; d[3] = 2 ; d[4] = 22 ;
d[5] = 7 ; d[6] = 8 ; d[7] = 4 ; d[8] = 6 ; d[9] = 17 ;
DummySVAL.quicksort (SVEmpty, d, 0, 9) ;
addTestResult ((d[0] == 2) && (d[1] == 3) && (d[2] == 4) && (d[3] == 6) && (d[4] == 7) &&
(d[5] == 8) && (d[6] == 8) && (d[7] == 12) && (d[8] == 17) && (d[9] == 22)) ;
delete[] d ;
}
}
|