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