Revision Log
Revision: 1.1 - (view) (download) (as text)
| 1 : | ktanaka | 1.1 | #include <strstream> |
| 2 : | #include "BitmapFontTest.h" | ||
| 3 : | |||
| 4 : | void BitmapFontTest::setUp(){ | ||
| 5 : | space=new BitmapFont(24,24); | ||
| 6 : | a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); | ||
| 7 : | } | ||
| 8 : | void BitmapFontTest::tearDown(){ | ||
| 9 : | delete space; delete a; | ||
| 10 : | } | ||
| 11 : | void BitmapFontTest::testGet(){ | ||
| 12 : | CPPUNIT_ASSERT( space->get(10,10) == false ); | ||
| 13 : | CPPUNIT_ASSERT( (*a).get(10,1) == true ); | ||
| 14 : | CPPUNIT_ASSERT( (*a).get(-10,1) == false ); | ||
| 15 : | CPPUNIT_ASSERT( (*a).get(100,1) == false ); | ||
| 16 : | CPPUNIT_ASSERT( (*a).get(10,-10) == false ); | ||
| 17 : | CPPUNIT_ASSERT( (*a).get(10,100) == false ); | ||
| 18 : | } | ||
| 19 : | static const char *showImage= | ||
| 20 : | ".....................@@.\n" | ||
| 21 : | "@@@@@@@@@@@@@@@@@@@@@@@@\n" | ||
| 22 : | "........@@....@@........\n" | ||
| 23 : | "........@@....@@........\n" | ||
| 24 : | "........@@....@@........\n" | ||
| 25 : | "........@@....@@........\n" | ||
| 26 : | "..@.....@@....@@....@@..\n" | ||
| 27 : | "..@@@@@@@@@@@@@@@@@@@@@.\n" | ||
| 28 : | "..@@....@@....@@....@@..\n" | ||
| 29 : | "..@@....@@....@@....@@..\n" | ||
| 30 : | "..@@....@@....@@....@@..\n" | ||
| 31 : | "..@@....@@....@@....@@..\n" | ||
| 32 : | "..@@....@@....@@....@@..\n" | ||
| 33 : | "..@@....@@....@@....@@..\n" | ||
| 34 : | "..@@@@@@@@@@@@@@@@@@@@..\n" | ||
| 35 : | "..@@....@@....@@....@@..\n" | ||
| 36 : | "........@@....@@........\n" | ||
| 37 : | "........@@....@@........\n" | ||
| 38 : | "........@@....@@........\n" | ||
| 39 : | "........@@....@@........\n" | ||
| 40 : | "........@@....@@........\n" | ||
| 41 : | "........@@....@@.....@@.\n" | ||
| 42 : | "@@@@@@@@@@@@@@@@@@@@@@@@\n" | ||
| 43 : | "........................\n"; | ||
| 44 : | |||
| 45 : | void BitmapFontTest::testShow(){ | ||
| 46 : | std::ostrstream os; | ||
| 47 : | os << *a; | ||
| 48 : | os.freeze(); | ||
| 49 : | CPPUNIT_ASSERT( os.pcount() == strlen(showImage)); | ||
| 50 : | CPPUNIT_ASSERT( !strncmp(os.str(),showImage,sizeof(showImage))); | ||
| 51 : | } | ||
| 52 : | void BitmapFontTest::testPixel(){ | ||
| 53 : | CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(0,1)) == 2); | ||
| 54 : | CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(22,0)) == 1); | ||
| 55 : | } |
|
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |