[wadalabfont-kit] / jis2prim / PatMatchTest.cc  

View of /jis2prim/PatMatchTest.cc

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

void PatMatchTest::setUp(){
  /*
    .....................@@.
    @@@@@@@@@@@@@@@@@@@@@@@@
    ........@@....@@........
    ........@@....@@........
    ........@@....@@........
    ........@@....@@........
    ..@.....@@....@@....@@..
    ..@@@@@@@@@@@@@@@@@@@@@.
    ..@@....@@....@@....@@..
    ..@@....@@....@@....@@..
    ..@@....@@....@@....@@..
    ..@@....@@....@@....@@..
    ..@@....@@....@@....@@..
    ..@@....@@....@@....@@..
    ..@@@@@@@@@@@@@@@@@@@@..
    ..@@....@@....@@....@@..
    ........@@....@@........
    ........@@....@@........
    ........@@....@@........
    ........@@....@@........
    ........@@....@@........
    ........@@....@@.....@@.
    @@@@@@@@@@@@@@@@@@@@@@@@
    ........................
  */
  
  a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000");
  pat1=new PatMatch(3,3,
		    "..."
		    ".@@"
		    "...",Assumption());
  pat2=new PatMatch(4,3,
		    "...."
		    "@@@@"
		    ".@@.",Assumption());
}
void PatMatchTest::tearDown(){
  delete a; delete pat1; delete pat2;
}
static const char *showImage=
"PatMatch(width=3,height=3,pat=....@@...,Assumption())";
void PatMatchTest::testShow(){
  std::ostrstream os;
  os << *pat1;
  os.freeze();
  CPPUNIT_ASSERT( os.pcount() == strlen(showImage));
  CPPUNIT_ASSERT( !strncmp(os.str(),showImage,sizeof(showImage)));
}
void PatMatchTest::testPixel(){
  std::vector<pixel> ps=pat1->getPixels(10,10);
  std::vector<pixel> ps1;
  ps1.push_back(pixel(11,11));
  ps1.push_back(pixel(12,11));
  CPPUNIT_ASSERT( ps == ps1 );
}
void PatMatchTest::testMatch(){
  CPPUNIT_ASSERT( pat1->matchPenalty(*a,-1,0) >=0);
  CPPUNIT_ASSERT( pat1->matchPenalty(*a,0,0) <0);
  CPPUNIT_ASSERT( pat2->matchPenalty(*a,7,0) >=0);
  CPPUNIT_ASSERT( pat2->matchPenalty(*a,7,6) <0);
  
}

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help