Revision: 1.1 - (view) (download) (as text)
1 : | ktanaka | 1.1 | #include <strstream> |
2 : | #include "PatMatchTest.h" | ||
3 : | |||
4 : | void PatMatchTest::setUp(){ | ||
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 : | a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); | ||
33 : | pat1=new PatMatch(3,3, | ||
34 : | "..." | ||
35 : | ".@@" | ||
36 : | "...",Assumption()); | ||
37 : | pat2=new PatMatch(4,3, | ||
38 : | "...." | ||
39 : | "@@@@" | ||
40 : | ".@@.",Assumption()); | ||
41 : | } | ||
42 : | void PatMatchTest::tearDown(){ | ||
43 : | delete a; delete pat1; delete pat2; | ||
44 : | } | ||
45 : | static const char *showImage= | ||
46 : | "PatMatch(width=3,height=3,pat=....@@...,Assumption())"; | ||
47 : | void PatMatchTest::testShow(){ | ||
48 : | std::ostrstream os; | ||
49 : | os << *pat1; | ||
50 : | os.freeze(); | ||
51 : | CPPUNIT_ASSERT( os.pcount() == strlen(showImage)); | ||
52 : | CPPUNIT_ASSERT( !strncmp(os.str(),showImage,sizeof(showImage))); | ||
53 : | } | ||
54 : | void PatMatchTest::testPixel(){ | ||
55 : | std::vector<pixel> ps=pat1->getPixels(10,10); | ||
56 : | std::vector<pixel> ps1; | ||
57 : | ps1.push_back(pixel(11,11)); | ||
58 : | ps1.push_back(pixel(12,11)); | ||
59 : | CPPUNIT_ASSERT( ps == ps1 ); | ||
60 : | } | ||
61 : | void PatMatchTest::testMatch(){ | ||
62 : | CPPUNIT_ASSERT( pat1->matchPenalty(*a,-1,0) >=0); | ||
63 : | CPPUNIT_ASSERT( pat1->matchPenalty(*a,0,0) <0); | ||
64 : | CPPUNIT_ASSERT( pat2->matchPenalty(*a,7,0) >=0); | ||
65 : | CPPUNIT_ASSERT( pat2->matchPenalty(*a,7,6) <0); | ||
66 : | |||
67 : | } |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |