[wadalabfont-kit] / jis2prim / PatMatchTest.h  

View of /jis2prim/PatMatchTest.h

Parent Directory | Revision Log
Revision: 1.2 - (download) (as text) (annotate)
Fri Feb 22 12:03:48 2002 UTC (22 years, 3 months ago) by ktanaka
Branch: MAIN
Changes since 1.1: +7 -0 lines
*** empty log message ***
#ifndef _PAT_MAT_TEST_H
#define _PAT_MAT_TEST_H
#include <cppunit/TestCase.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestResult.h>
#include <cppunit/TextTestRunner.h>
#include "PatMatch.h"

using namespace CppUnit;

class PatMatchTest : public TestCase {
 private:
  BitmapFont *a;
  PatMatch *pat1,*pat2;
 public:
  void setUp(){
    /*
.....................@@.
@@@@@@@@@@@@@@@@@@@@@@@@
........@@....@@........
........@@....@@........
........@@....@@........
........@@....@@........
..@.....@@....@@....@@..
..@@@@@@@@@@@@@@@@@@@@@.
..@@....@@....@@....@@..
..@@....@@....@@....@@..
..@@....@@....@@....@@..
..@@....@@....@@....@@..
..@@....@@....@@....@@..
..@@....@@....@@....@@..
..@@@@@@@@@@@@@@@@@@@@..
..@@....@@....@@....@@..
........@@....@@........
........@@....@@........
........@@....@@........
........@@....@@........
........@@....@@........
........@@....@@.....@@.
@@@@@@@@@@@@@@@@@@@@@@@@
........................
    */

    a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000");
    pat1=new PatMatch(3,3,
		     "..."
		     ".@@"
		     "...",Assumption());
    pat2=new PatMatch(4,3,
		     "...."
		     "@@@@"
		     ".@@.",Assumption());
  }
  void tearDown(){
    delete a; delete pat1; delete pat2;
  }
  void testShow(){
    cout << *pat1 << '\n';
    vector<pixel> ps=pat1->getPixels(10,10);
    vector<pixel>::iterator it;
    for(it=ps.begin();it!=ps.end();it++){
      cout << '(' << it->first << ',' << it->second << ')';
    }
    cout << '\n';
  }
  void testMatch(){
    CPPUNIT_ASSERT( pat1->isMatch(*a,-1,0) == true );
    CPPUNIT_ASSERT( pat1->isMatch(*a,0,0) == false );
    CPPUNIT_ASSERT( pat2->isMatch(*a,7,0) == true );
    CPPUNIT_ASSERT( pat2->isMatch(*a,7,6) == false );
    
  }
  static Test *suite(){
    TestSuite *suiteOfTests = new TestSuite;
    suiteOfTests->addTest (new TestCaller<PatMatchTest>("testShow", &PatMatchTest::testShow));
    suiteOfTests->addTest (new TestCaller<PatMatchTest>("testMatch", &PatMatchTest::testMatch));
    return suiteOfTests;
  }
};


#endif /* _PAT_MAT_TEST_H */

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help