Commit aea26d362f0c311efe01aec34dd02c9ee5fc8ca4

sammy 2008-04-13T00:53:33

* Build cppunit tests using the autotools.

diff --git a/Makefile.am b/Makefile.am
index 88815a3..f070dc4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = src demo docs
+SUBDIRS = src test demo docs
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = ftgl.pc
diff --git a/configure.ac b/configure.ac
index e1646b0..88c7af3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,10 @@ AC_PATH_XTRA
 FTGL_CHECK_GL
 FTGL_CHECK_GLUT
 
+CPPUNIT="no"
+PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [AC_MSG_RESULT(no)])
+AM_CONDITIONAL(HAVE_CPPUNIT, test "$CPPUNIT" != "no")
+
 # Checks for library functions
 dnl This isn't really used at the moment
 
@@ -47,6 +51,7 @@ AC_CONFIG_FILES([
 AC_CONFIG_FILES([
   Makefile
   src/Makefile
+  test/Makefile
   docs/Makefile
   demo/Makefile
 ])
diff --git a/test/FTGLExtrdFont-Test.cpp b/test/FTGLExtrdFont-Test.cpp
new file mode 100644
index 0000000..971bcfe
--- /dev/null
+++ b/test/FTGLExtrdFont-Test.cpp
@@ -0,0 +1,104 @@
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCaller.h>
+#include <cppunit/TestCase.h>
+#include <cppunit/TestSuite.h>
+#include <assert.h>
+
+#include "Fontdefs.h"
+#include "FTGLExtrdFont.h"
+
+extern void buildGLContext();
+
+class FTGLExtrdFontTest : public CppUnit::TestCase
+{
+    CPPUNIT_TEST_SUITE( FTGLExtrdFontTest);
+        CPPUNIT_TEST( testConstructor);
+        CPPUNIT_TEST( testRender);
+        CPPUNIT_TEST( testBadDisplayList);
+        CPPUNIT_TEST( testGoodDisplayList);
+    CPPUNIT_TEST_SUITE_END();
+        
+    public:
+        FTGLExtrdFontTest() : CppUnit::TestCase( "FTGLExtrdFont Test")
+        {
+        }
+        
+        FTGLExtrdFontTest( const std::string& name) : CppUnit::TestCase(name) {}
+        
+        ~FTGLExtrdFontTest()
+        {
+        }
+        
+        void testConstructor()
+        {
+            buildGLContext();
+        
+            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);            
+            CPPUNIT_ASSERT( extrudedFont->Error() == 0);
+        
+            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
+        }
+
+        void testRender()
+        {
+            buildGLContext();
+        
+            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);            
+            extrudedFont->Render(GOOD_ASCII_TEST_STRING);
+
+            CPPUNIT_ASSERT( extrudedFont->Error() == 0x97);   // Invalid pixels per em
+            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
+
+            extrudedFont->FaceSize(18);
+            extrudedFont->Render(GOOD_ASCII_TEST_STRING);
+
+            CPPUNIT_ASSERT( extrudedFont->Error() == 0);        
+            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
+        }
+        
+        void testBadDisplayList()
+        {
+            buildGLContext();
+        
+            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
+            extrudedFont->FaceSize(18);
+            
+            int glList = glGenLists(1);
+            glNewList( glList, GL_COMPILE);
+
+                extrudedFont->Render(GOOD_ASCII_TEST_STRING);
+
+            glEndList();
+
+            CPPUNIT_ASSERT( glGetError() == GL_INVALID_OPERATION);
+        }
+        
+        void testGoodDisplayList()
+        {
+            buildGLContext();
+        
+            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
+            extrudedFont->FaceSize(18);
+
+            extrudedFont->UseDisplayList(false);
+            int glList = glGenLists(1);
+            glNewList( glList, GL_COMPILE);
+
+                extrudedFont->Render(GOOD_ASCII_TEST_STRING);
+
+            glEndList();
+
+            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
+        }
+        
+        void setUp() 
+        {}
+        
+        void tearDown() 
+        {}
+                    
+    private:
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( FTGLExtrdFontTest);
+
diff --git a/test/FTGLExtrdFont.cpp-Test.cpp b/test/FTGLExtrdFont.cpp-Test.cpp
deleted file mode 100644
index 971bcfe..0000000
--- a/test/FTGLExtrdFont.cpp-Test.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCaller.h>
-#include <cppunit/TestCase.h>
-#include <cppunit/TestSuite.h>
-#include <assert.h>
-
-#include "Fontdefs.h"
-#include "FTGLExtrdFont.h"
-
-extern void buildGLContext();
-
-class FTGLExtrdFontTest : public CppUnit::TestCase
-{
-    CPPUNIT_TEST_SUITE( FTGLExtrdFontTest);
-        CPPUNIT_TEST( testConstructor);
-        CPPUNIT_TEST( testRender);
-        CPPUNIT_TEST( testBadDisplayList);
-        CPPUNIT_TEST( testGoodDisplayList);
-    CPPUNIT_TEST_SUITE_END();
-        
-    public:
-        FTGLExtrdFontTest() : CppUnit::TestCase( "FTGLExtrdFont Test")
-        {
-        }
-        
-        FTGLExtrdFontTest( const std::string& name) : CppUnit::TestCase(name) {}
-        
-        ~FTGLExtrdFontTest()
-        {
-        }
-        
-        void testConstructor()
-        {
-            buildGLContext();
-        
-            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);            
-            CPPUNIT_ASSERT( extrudedFont->Error() == 0);
-        
-            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
-        }
-
-        void testRender()
-        {
-            buildGLContext();
-        
-            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);            
-            extrudedFont->Render(GOOD_ASCII_TEST_STRING);
-
-            CPPUNIT_ASSERT( extrudedFont->Error() == 0x97);   // Invalid pixels per em
-            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
-
-            extrudedFont->FaceSize(18);
-            extrudedFont->Render(GOOD_ASCII_TEST_STRING);
-
-            CPPUNIT_ASSERT( extrudedFont->Error() == 0);        
-            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);        
-        }
-        
-        void testBadDisplayList()
-        {
-            buildGLContext();
-        
-            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
-            extrudedFont->FaceSize(18);
-            
-            int glList = glGenLists(1);
-            glNewList( glList, GL_COMPILE);
-
-                extrudedFont->Render(GOOD_ASCII_TEST_STRING);
-
-            glEndList();
-
-            CPPUNIT_ASSERT( glGetError() == GL_INVALID_OPERATION);
-        }
-        
-        void testGoodDisplayList()
-        {
-            buildGLContext();
-        
-            FTGLExtrdFont* extrudedFont = new FTGLExtrdFont( FONT_FILE);
-            extrudedFont->FaceSize(18);
-
-            extrudedFont->UseDisplayList(false);
-            int glList = glGenLists(1);
-            glNewList( glList, GL_COMPILE);
-
-                extrudedFont->Render(GOOD_ASCII_TEST_STRING);
-
-            glEndList();
-
-            CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
-        }
-        
-        void setUp() 
-        {}
-        
-        void tearDown() 
-        {}
-                    
-    private:
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION( FTGLExtrdFontTest);
-
diff --git a/test/FTGlyph-Test.cpp b/test/FTGlyph-Test.cpp
index a8d9364..76adc99 100644
--- a/test/FTGlyph-Test.cpp
+++ b/test/FTGlyph-Test.cpp
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/TestCaller.h>
 #include <cppunit/TestCase.h>
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..fc0d57e
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,50 @@
+
+if HAVE_CPPUNIT
+if HAVE_GLUT
+noinst_PROGRAMS = FTGLTest
+endif
+endif
+
+FTGLTest_SOURCES = \
+    TestMain.cpp \
+    Fontdefs.h \
+    FTBBox-Test.cpp \
+    FTBitmapGlyph-Test.cpp \
+    FTCharmap-Test.cpp \
+    FTCharToGlyphIndexMap-Test.cpp \
+    FTContour-Test.cpp \
+    FTExtrdGlyph-Test.cpp \
+    FTFace-Test.cpp \
+    FTFont-Test.cpp \
+    FTGLBitmapFont-Test.cpp \
+    FTGLExtrdFont-Test.cpp \
+    FTGLOutlineFont-Test.cpp \
+    FTGLPixmapFont-Test.cpp \
+    FTGLPolygonFont-Test.cpp \
+    FTGLTextureFont-Test.cpp \
+    FTGlyphContainer-Test.cpp \
+    FTGlyph-Test.cpp \
+    FTLibrary-Test.cpp \
+    FTList-Test.cpp \
+    FTMesh-Test.cpp \
+    FTOutlineGlyph-Test.cpp \
+    FTPixmapGlyph-Test.cpp \
+    FTPoint-Test.cpp \
+    FTPolyGlyph-Test.cpp \
+    FTSize-Test.cpp \
+    FTTesselation-Test.cpp \
+    FTTextureGlyph-Test.cpp \
+    FTVectoriser-Test.cpp \
+    FTVector-Test.cpp \
+    HPGCalc_afm.cpp \
+    HPGCalc_pfb.cpp \
+    $(NULL)
+FTGLTest_CPPFLAGS = -I$(top_srcdir)/include
+FTGLTest_CXXFLAGS = $(FT2_CFLAGS) $(GL_CFLAGS)
+FTGLTest_LDFLAGS = $(FT2_LIBS) $(GLUT_LIBS) -lcppunit
+FTGLTest_LDADD = ../src/libftgl.la
+
+DEACTIVATED = \
+    FTlayout-Test.cpp \
+    $(NULL)
+