More tests
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
diff --git a/test/FTMesh-Test.cpp b/test/FTMesh-Test.cpp
index 7930e71..8d58f09 100755
--- a/test/FTMesh-Test.cpp
+++ b/test/FTMesh-Test.cpp
@@ -30,6 +30,7 @@ static float POINT_DATA[] =
class FTMeshTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( FTMeshTest);
+ CPPUNIT_TEST( testGetTesselation);
CPPUNIT_TEST( testAddPoint);
CPPUNIT_TEST( testTooManyPoints);
CPPUNIT_TEST_SUITE_END();
@@ -41,6 +42,24 @@ class FTMeshTest : public CppUnit::TestCase
FTMeshTest( const std::string& name) : CppUnit::TestCase(name)
{}
+ void testGetTesselation()
+ {
+ FTMesh mesh;
+
+ CPPUNIT_ASSERT( mesh.Tesselation(0) == NULL);
+
+ ftglBegin( GL_TRIANGLES, &mesh);
+ ftglVertex( &POINT_DATA[0], &mesh);
+ ftglVertex( &POINT_DATA[3], &mesh);
+ ftglVertex( &POINT_DATA[6], &mesh);
+ ftglVertex( &POINT_DATA[9], &mesh);
+ ftglEnd( &mesh);
+
+ CPPUNIT_ASSERT( mesh.Tesselation(0));
+ CPPUNIT_ASSERT( mesh.Tesselation(10) == NULL);
+ }
+
+
void testAddPoint()
{
FTGL_DOUBLE testPoint[3] = { 1, 2, 3};
@@ -48,7 +67,6 @@ class FTMeshTest : public CppUnit::TestCase
FTMesh mesh;
CPPUNIT_ASSERT( mesh.TesselationCount() == 0);
- CPPUNIT_ASSERT( mesh.Tesselation(0)->PointCount() == 0);
ftglBegin( GL_TRIANGLES, &mesh);
ftglVertex( &POINT_DATA[0], &mesh);
@@ -94,15 +112,21 @@ class FTMeshTest : public CppUnit::TestCase
ftglBegin( GL_TRIANGLES, &mesh);
ftglCombine( testPoint, NULL, NULL, (void**)testOutput, &mesh);
- for( unsigned int x = 0; x < 300; ++x)
+ for( unsigned int x = 0; x < 200; ++x)
{
ftglCombine( testPoint, NULL, NULL, (void**)hole, &mesh);
}
+
+ CPPUNIT_ASSERT( *testOutput == &(mesh.tempPointList[0].x));
+ for( unsigned int x = 201; x < 300; ++x)
+ {
+ ftglCombine( testPoint, NULL, NULL, (void**)hole, &mesh);
+ }
+
ftglEnd( &mesh);
CPPUNIT_ASSERT( *testOutput == &(mesh.tempPointList[0].x));
-
}
void setUp()
diff --git a/test/FTTesselation-Test.cpp b/test/FTTesselation-Test.cpp
index 7a0716d..1c665cf 100755
--- a/test/FTTesselation-Test.cpp
+++ b/test/FTTesselation-Test.cpp
@@ -10,6 +10,7 @@ class FTTesselationTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE( FTTesselationTest);
CPPUNIT_TEST( testAddPoint);
+ CPPUNIT_TEST( testGetPoint);
CPPUNIT_TEST_SUITE_END();
public:
@@ -41,6 +42,23 @@ class FTTesselationTest : public CppUnit::TestCase
}
+ void testGetPoint()
+ {
+ FTTesselation tesselation;
+
+ CPPUNIT_ASSERT( tesselation.PointCount() == 0);
+
+ tesselation.AddPoint( 10, 3, 0.7);
+ tesselation.AddPoint( -53, 2000, 23);
+ tesselation.AddPoint( 77, -2.4, 765);
+ tesselation.AddPoint( 117.5, 0.02, -99);
+
+ CPPUNIT_ASSERT( tesselation.PointCount() == 4);
+ CPPUNIT_ASSERT( tesselation.Point(2) == FTPoint( 77, -2.4, 765));
+ CPPUNIT_ASSERT( tesselation.Point(20) != FTPoint( 77, -2.4, 765));
+ }
+
+
void setUp()
{}
diff --git a/test/FTVectoriser-Test.cpp b/test/FTVectoriser-Test.cpp
index 3d53a2e..07b4d00 100755
--- a/test/FTVectoriser-Test.cpp
+++ b/test/FTVectoriser-Test.cpp
@@ -258,8 +258,10 @@ class FTVectoriserTest : public CppUnit::TestCase
CPPUNIT_TEST( testBadGlyphProcess);
CPPUNIT_TEST( testSimpleGlyphProcess);
CPPUNIT_TEST( testComplexGlyphProcess);
+ CPPUNIT_TEST( testGetContour);
CPPUNIT_TEST( testGetOutline);
CPPUNIT_TEST( testGetMesh);
+ CPPUNIT_TEST( testMakeMesh);
CPPUNIT_TEST_SUITE_END();
public:
@@ -316,6 +318,20 @@ class FTVectoriserTest : public CppUnit::TestCase
}
+ void testGetContour()
+ {
+ setUpFreetype();
+ loadGlyph( SIMPLE_CHARACTER_INDEX);
+
+ FTVectoriser vectoriser( glyph);
+
+ CPPUNIT_ASSERT( vectoriser.Contour(1));
+ CPPUNIT_ASSERT( vectoriser.Contour(99) == NULL);
+
+ tearDownFreetype();
+ }
+
+
void testGetOutline()
{
setUpFreetype();
@@ -326,7 +342,7 @@ class FTVectoriserTest : public CppUnit::TestCase
unsigned int d = 0;
for( size_t c = 0; c < vectoriser.ContourCount(); ++c)
{
- FTContour* contour = vectoriser.Contour(c);
+ const FTContour* contour = vectoriser.Contour(c);
for( size_t p = 0; p < contour->PointCount(); ++p)
{
@@ -343,6 +359,20 @@ class FTVectoriserTest : public CppUnit::TestCase
void testGetMesh()
{
setUpFreetype();
+ loadGlyph( SIMPLE_CHARACTER_INDEX);
+
+ FTVectoriser vectoriser( glyph);
+ CPPUNIT_ASSERT( vectoriser.GetMesh() == NULL);
+
+ vectoriser.MakeMesh(1.0);
+
+ CPPUNIT_ASSERT( vectoriser.GetMesh());
+ }
+
+
+ void testMakeMesh()
+ {
+ setUpFreetype();
loadGlyph( COMPLEX_CHARACTER_INDEX);
FTVectoriser vectoriser( glyph);
@@ -350,13 +380,13 @@ class FTVectoriserTest : public CppUnit::TestCase
vectoriser.MakeMesh(1.0);
int d = 0;
- FTMesh* mesh = vectoriser.GetMesh();
+ const FTMesh* mesh = vectoriser.GetMesh();
unsigned int tesselations = mesh->TesselationCount();
CPPUNIT_ASSERT( tesselations == 14);
for( unsigned int index = 0; index < tesselations; ++index)
{
- FTTesselation* subMesh = mesh->Tesselation( index);
+ const FTTesselation* subMesh = mesh->Tesselation( index);
unsigned int polyType = subMesh->PolygonType();
CPPUNIT_ASSERT( testMeshPolygonTypes[index] == polyType);