Added testCheckGlyphFailure test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/test/FTFont-Test.cpp b/test/FTFont-Test.cpp
index 03859bc..6ee5e9a 100755
--- a/test/FTFont-Test.cpp
+++ b/test/FTFont-Test.cpp
@@ -13,9 +13,7 @@ class TestGlyph : public FTGlyph
public:
TestGlyph( FT_GlyphSlot glyph)
: FTGlyph( glyph)
- {
-// FT_Done_Glyph( glyph );
- }
+ {}
float Render( const FTPoint& pen){ return advance;}
};
@@ -48,6 +46,44 @@ class TestFont : public FTFont
};
+class BadGlyphTestFont : public FTFont
+{
+ public:
+ BadGlyphTestFont( const char* fontname)
+ : FTFont( fontname)
+ {}
+
+ FTGlyph* MakeGlyph( unsigned int g)
+ {
+ FT_GlyphSlot ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
+
+ if( ftGlyph)
+ {
+ TestGlyph* tempGlyph = new TestGlyph( ftGlyph);
+ return tempGlyph;
+ }
+
+ err = face.Error();
+ return NULL;
+ }
+
+ private:
+ bool CheckGlyph( const unsigned int chr)
+ {
+ static bool succeed = false;
+
+ if( succeed == false)
+ {
+ succeed = true;
+ return false;
+ }
+
+ return true;
+ }
+
+};
+
+
class FTFontTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( FTFontTest);
@@ -59,6 +95,7 @@ class FTFontTest : public CppUnit::TestCase
CPPUNIT_TEST( testSetCharMap);
CPPUNIT_TEST( testGetCharmapList);
CPPUNIT_TEST( testBoundingBox);
+ CPPUNIT_TEST( testCheckGlyphFailure);
CPPUNIT_TEST( testAdvance);
CPPUNIT_TEST( testRender);
CPPUNIT_TEST_SUITE_END();
@@ -204,6 +241,13 @@ class FTFontTest : public CppUnit::TestCase
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urz, 0.01);
}
+ void testCheckGlyphFailure()
+ {
+ BadGlyphTestFont* testFont = new BadGlyphTestFont(GOOD_FONT_FILE);
+
+ float advance = testFont->Advance( GOOD_ASCII_TEST_STRING);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, advance, 0.01);
+ }
void testAdvance()
{