#include <cppunit/TestSuite.h> |
#include <cppunit/TestSuite.h> |
#include <cppunit/TestResult.h> |
#include <cppunit/TestResult.h> |
#include <cppunit/TextTestRunner.h> |
#include <cppunit/TextTestRunner.h> |
|
#include <cppunit/extensions/HelperMacros.h> |
#include "BitmapFont.h" |
#include "BitmapFont.h" |
#include <iostream> |
#include <iostream> |
#include <algorithm> |
#include <algorithm> |
|
|
using namespace CppUnit; |
class BitmapFontTest : public CppUnit::TestFixture { |
|
CPPUNIT_TEST_SUITE( BitmapFontTest ); |
class BitmapFontTest : public TestCase { |
CPPUNIT_TEST( testGet ); |
|
CPPUNIT_TEST( testShow ); |
|
CPPUNIT_TEST( testPixel ); |
|
CPPUNIT_TEST_SUITE_END(); |
private: |
private: |
BitmapFont *space, *a; |
BitmapFont *space, *a; |
public: |
public: |
void setUp(){ |
void setUp(); |
space=new BitmapFont(24,24); |
void tearDown(); |
a=new BitmapFont(24,24,"000006FFFFFF00C30000C30000C30000C30020C30C3FFFFE30C30C30C30C30C30C30C30C30C30C30C30C3FFFFC30C30C00C30000C30000C30000C30000C30000C306FFFFFF000000"); |
void testGet(); |
} |
void testShow(); |
void tearDown(){ |
void testPixel(); |
delete space; delete a; |
|
} |
|
void 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 ); |
|
} |
|
void testShow(){ |
|
std::cout << "a\n"; |
|
std::cout << *a << "\n"; |
|
std::cout << "space\n"; |
|
std::cout << *space << "\n"; |
|
} |
|
void testPixel(){ |
|
CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(0,1)) == 2); |
|
CPPUNIT_ASSERT( (*a).getIndex(std::pair<int,int>(22,0)) == 1); |
|
} |
|
static Test *suite() { |
|
TestSuite *suiteOfTests = new TestSuite; |
|
suiteOfTests->addTest (new TestCaller<BitmapFontTest>("testGet", &BitmapFontTest::testGet)); |
|
suiteOfTests->addTest (new TestCaller<BitmapFontTest>("testShow", &BitmapFontTest::testShow)); |
|
suiteOfTests->addTest (new TestCaller<BitmapFontTest>("testPixel", &BitmapFontTest::testPixel)); |
|
return suiteOfTests; |
|
} |
|
}; |
}; |
|
|
#endif /* _BITMAP_FONT_TEST_H */ |
#endif /* _BITMAP_FONT_TEST_H */ |