Revision: 1.2 - (view) (download) (as text)
1 : | ktanaka | 1.1 | |
2 : | #ifndef _MATCHERS_TEST_TEST_H | ||
3 : | #define _MATCHERS_TEST_TEST_H | ||
4 : | #include <cppunit/TestCase.h> | ||
5 : | #include <cppunit/TestCaller.h> | ||
6 : | #include <cppunit/TestSuite.h> | ||
7 : | #include <cppunit/TestResult.h> | ||
8 : | #include <cppunit/TextTestRunner.h> | ||
9 : | #include "Matchers.h" | ||
10 : | |||
11 : | using namespace CppUnit; | ||
12 : | |||
13 : | class MatchersTest : public TestCase { | ||
14 : | private: | ||
15 : | BitmapFont *a; | ||
16 : | Matchers *mat; | ||
17 : | ktanaka | 1.2 | BitmapFontFile *ff; |
18 : | ktanaka | 1.1 | public: |
19 : | void setUp(){ | ||
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 : | a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); | ||
48 : | mat=new Matchers(); | ||
49 : | ktanaka | 1.2 | ff=new BitmapFontFile("jiskan24.bdf"); |
50 : | ktanaka | 1.1 | } |
51 : | void tearDown(){ | ||
52 : | delete a; delete mat; | ||
53 : | ktanaka | 1.2 | delete ff; |
54 : | ktanaka | 1.1 | } |
55 : | void testShow(){ | ||
56 : | cout << *mat << '\n'; | ||
57 : | } | ||
58 : | void testMatch(){ | ||
59 : | vector<MatchResult> mr=mat->findMatch(*a); | ||
60 : | vector<MatchResult>::iterator it; | ||
61 : | for(it=mr.begin();it!=mr.end();it++) | ||
62 : | cout << *it << '\n'; | ||
63 : | } | ||
64 : | ktanaka | 1.2 | void testCover(){ |
65 : | for(int code=0x3021;code<=0x307e;code++){ | ||
66 : | BitmapFont bf=ff->find(code); | ||
67 : | vector<pixel> nc=mat->notCovered(bf); | ||
68 : | if(!nc.empty()){ | ||
69 : | cout << "---------------------------------------\n"; | ||
70 : | cout << bf; | ||
71 : | cout << BitmapFont(bf.getWidth(),bf.getHeight(),nc) ; | ||
72 : | } | ||
73 : | } | ||
74 : | } | ||
75 : | ktanaka | 1.1 | static Test *suite(){ |
76 : | TestSuite *suiteOfTests = new TestSuite; | ||
77 : | suiteOfTests->addTest (new TestCaller<MatchersTest>("testShow", &MatchersTest::testShow)); | ||
78 : | suiteOfTests->addTest (new TestCaller<MatchersTest>("testMatch", &MatchersTest::testMatch)); | ||
79 : | ktanaka | 1.2 | suiteOfTests->addTest (new TestCaller<MatchersTest>("testCover", &MatchersTest::testCover)); |
80 : | ktanaka | 1.1 | return suiteOfTests; |
81 : | } | ||
82 : | }; | ||
83 : | |||
84 : | #endif /* _MATCHERS_TEST_TEST_H */ |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |