Revision: 1.2 - (view) (download) (as text)
1 : | ktanaka | 1.1 | #ifndef _PAT_MAT_TEST_H |
2 : | #define _PAT_MAT_TEST_H | ||
3 : | #include <cppunit/TestCase.h> | ||
4 : | #include <cppunit/TestCaller.h> | ||
5 : | #include <cppunit/TestSuite.h> | ||
6 : | #include <cppunit/TestResult.h> | ||
7 : | #include <cppunit/TextTestRunner.h> | ||
8 : | #include "PatMatch.h" | ||
9 : | |||
10 : | using namespace CppUnit; | ||
11 : | |||
12 : | class PatMatchTest : public TestCase { | ||
13 : | private: | ||
14 : | BitmapFont *a; | ||
15 : | PatMatch *pat1,*pat2; | ||
16 : | public: | ||
17 : | void setUp(){ | ||
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 : | a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); | ||
46 : | pat1=new PatMatch(3,3, | ||
47 : | "..." | ||
48 : | ".@@" | ||
49 : | "...",Assumption()); | ||
50 : | pat2=new PatMatch(4,3, | ||
51 : | "...." | ||
52 : | "@@@@" | ||
53 : | ".@@.",Assumption()); | ||
54 : | } | ||
55 : | void tearDown(){ | ||
56 : | delete a; delete pat1; delete pat2; | ||
57 : | } | ||
58 : | void testShow(){ | ||
59 : | ktanaka | 1.2 | cout << *pat1 << '\n'; |
60 : | vector<pixel> ps=pat1->getPixels(10,10); | ||
61 : | vector<pixel>::iterator it; | ||
62 : | for(it=ps.begin();it!=ps.end();it++){ | ||
63 : | cout << '(' << it->first << ',' << it->second << ')'; | ||
64 : | } | ||
65 : | cout << '\n'; | ||
66 : | ktanaka | 1.1 | } |
67 : | void testMatch(){ | ||
68 : | CPPUNIT_ASSERT( pat1->isMatch(*a,-1,0) == true ); | ||
69 : | CPPUNIT_ASSERT( pat1->isMatch(*a,0,0) == false ); | ||
70 : | CPPUNIT_ASSERT( pat2->isMatch(*a,7,0) == true ); | ||
71 : | CPPUNIT_ASSERT( pat2->isMatch(*a,7,6) == false ); | ||
72 : | |||
73 : | } | ||
74 : | static Test *suite(){ | ||
75 : | TestSuite *suiteOfTests = new TestSuite; | ||
76 : | suiteOfTests->addTest (new TestCaller<PatMatchTest>("testShow", &PatMatchTest::testShow)); | ||
77 : | suiteOfTests->addTest (new TestCaller<PatMatchTest>("testMatch", &PatMatchTest::testMatch)); | ||
78 : | return suiteOfTests; | ||
79 : | } | ||
80 : | }; | ||
81 : | |||
82 : | |||
83 : | #endif /* _PAT_MAT_TEST_H */ |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |