#include <cppunit/TestSuite.h> |
#include <cppunit/TestSuite.h> |
#include <cppunit/TestResult.h> |
#include <cppunit/TestResult.h> |
#include <cppunit/TextTestRunner.h> |
#include <cppunit/TextTestRunner.h> |
|
#include <cppunit/extensions/HelperMacros.h> |
#include "PatMatch.h" |
#include "PatMatch.h" |
|
#include <vector> |
|
#include <iostream> |
|
|
using namespace CppUnit; |
class PatMatchTest : public CppUnit::TestFixture { |
|
CPPUNIT_TEST_SUITE( PatMatchTest ); |
class PatMatchTest : public TestCase { |
CPPUNIT_TEST( testShow ); |
|
CPPUNIT_TEST( testPixel ); |
|
CPPUNIT_TEST( testMatch ); |
|
CPPUNIT_TEST_SUITE_END(); |
private: |
private: |
BitmapFont *a; |
BitmapFont *a; |
PatMatch *pat1,*pat2; |
PatMatch *pat1,*pat2; |
public: |
public: |
void setUp(){ |
void setUp(); |
/* |
void tearDown(); |
.....................@@. |
void testShow(); |
@@@@@@@@@@@@@@@@@@@@@@@@ |
void testPixel(); |
........@@....@@........ |
void testMatch(); |
........@@....@@........ |
|
........@@....@@........ |
|
........@@....@@........ |
|
..@.....@@....@@....@@.. |
|
..@@@@@@@@@@@@@@@@@@@@@. |
|
..@@....@@....@@....@@.. |
|
..@@....@@....@@....@@.. |
|
..@@....@@....@@....@@.. |
|
..@@....@@....@@....@@.. |
|
..@@....@@....@@....@@.. |
|
..@@....@@....@@....@@.. |
|
..@@@@@@@@@@@@@@@@@@@@.. |
|
..@@....@@....@@....@@.. |
|
........@@....@@........ |
|
........@@....@@........ |
|
........@@....@@........ |
|
........@@....@@........ |
|
........@@....@@........ |
|
........@@....@@.....@@. |
|
@@@@@@@@@@@@@@@@@@@@@@@@ |
|
........................ |
|
*/ |
|
|
|
a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); |
|
pat1=new PatMatch(3,3, |
|
"..." |
|
".@@" |
|
"...",Assumption()); |
|
pat2=new PatMatch(4,3, |
|
"...." |
|
"@@@@" |
|
".@@.",Assumption()); |
|
} |
|
void tearDown(){ |
|
delete a; delete pat1; delete pat2; |
|
} |
|
void testShow(){ |
|
cout << *pat1 << '\n'; |
|
vector<pixel> ps=pat1->getPixels(10,10); |
|
vector<pixel>::iterator it; |
|
for(it=ps.begin();it!=ps.end();it++){ |
|
cout << '(' << it->first << ',' << it->second << ')'; |
|
} |
|
cout << '\n'; |
|
} |
|
void testMatch(){ |
|
CPPUNIT_ASSERT( pat1->isMatch(*a,-1,0) == true ); |
|
CPPUNIT_ASSERT( pat1->isMatch(*a,0,0) == false ); |
|
CPPUNIT_ASSERT( pat2->isMatch(*a,7,0) == true ); |
|
CPPUNIT_ASSERT( pat2->isMatch(*a,7,6) == false ); |
|
|
|
} |
|
static Test *suite(){ |
|
TestSuite *suiteOfTests = new TestSuite; |
|
suiteOfTests->addTest (new TestCaller<PatMatchTest>("testShow", &PatMatchTest::testShow)); |
|
suiteOfTests->addTest (new TestCaller<PatMatchTest>("testMatch", &PatMatchTest::testMatch)); |
|
return suiteOfTests; |
|
} |
|
}; |
}; |
|
|
|
|