Commit 8a9a8cf3b56792043e4d90e442b2b7b5f36887c3

henry 2002-12-19T10:29:36

More tests

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);