[wadalabfont-kit] / jis2prim / BitmapFontTest.cc  

View of /jis2prim/BitmapFontTest.cc

Parent Directory | Revision Log
Revision: 1.1 - (download) (as text) (annotate)
Tue Aug 20 11:10:36 2002 UTC (21 years, 8 months ago) by ktanaka
Branch: MAIN
CVS Tags: SNAP-20040518, SNAP-20030702, SNAP-20030630, SNAP-20030624, HEAD
*** empty log message ***
#include <strstream>
#include "BitmapFontTest.h"

void BitmapFontTest::setUp(){
  space=new BitmapFont(24,24);
  a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000");
}
void BitmapFontTest::tearDown(){
  delete space; delete a;
}
void BitmapFontTest::testGet(){
  CPPUNIT_ASSERT( space->get(10,10) == false );
  CPPUNIT_ASSERT( (*a).get(10,1) == true );
  CPPUNIT_ASSERT( (*a).get(-10,1) == false );
  CPPUNIT_ASSERT( (*a).get(100,1) == false );
  CPPUNIT_ASSERT( (*a).get(10,-10) == false );
  CPPUNIT_ASSERT( (*a).get(10,100) == false );
}
static const char *showImage=
".....................@@.\n"
"@@@@@@@@@@@@@@@@@@@@@@@@\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@........\n"
"..@.....@@....@@....@@..\n"
"..@@@@@@@@@@@@@@@@@@@@@.\n"
"..@@....@@....@@....@@..\n"
"..@@....@@....@@....@@..\n"
"..@@....@@....@@....@@..\n"
"..@@....@@....@@....@@..\n"
"..@@....@@....@@....@@..\n"
"..@@....@@....@@....@@..\n"
"..@@@@@@@@@@@@@@@@@@@@..\n"
"..@@....@@....@@....@@..\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@........\n"
"........@@....@@.....@@.\n"
"@@@@@@@@@@@@@@@@@@@@@@@@\n"
"........................\n";

void BitmapFontTest::testShow(){
  std::ostrstream os;
  os << *a;
  os.freeze();
  CPPUNIT_ASSERT( os.pcount() == strlen(showImage));
  CPPUNIT_ASSERT( !strncmp(os.str(),showImage,sizeof(showImage)));
}
void BitmapFontTest::testPixel(){
  CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(0,1)) == 2);
  CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(22,0)) == 1);
}

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help