Commit becb282adb74839c7f0d1c8eb4e7eddf931d4b71

henry 2002-12-17T23:28:16

Moved all the constants into a header

diff --git a/test/FTBBox-Test.cpp b/test/FTBBox-Test.cpp
index 94d4209..d3589ac 100755
--- a/test/FTBBox-Test.cpp
+++ b/test/FTBBox-Test.cpp
@@ -7,12 +7,9 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
+#include "Fontdefs.h"
 #include "FTBBox.h"
 
-static const int RESOLUTION = 72;
-static const int CHARACTER_INDEX = 'g';
-static const int CHARACTER_SIZE = 72 * 64;
-static const char* FONT_FILE = "../../test/MHei-Medium-Acro";
 
 class FTBBoxTest : public CppUnit::TestCase
 {
@@ -20,7 +17,6 @@ class FTBBoxTest : public CppUnit::TestCase
             CPPUNIT_TEST( testDefaultConstructor);
             CPPUNIT_TEST( testGlyphConstructor);
             CPPUNIT_TEST( testMoveBBox);
-//            CPPUNIT_TEST( testAddBBox);
             CPPUNIT_TEST( testPlusEquals);
         CPPUNIT_TEST_SUITE_END();
         
@@ -131,12 +127,12 @@ class FTBBoxTest : public CppUnit::TestCase
         {
             FT_Error error = FT_Init_FreeType( &library);
             assert(!error);
-            error = FT_New_Face( library, FONT_FILE, 0, &face);
+            error = FT_New_Face( library, GOOD_FONT_FILE, 0, &face);
             assert(!error);
             
-            long glyphIndex = FT_Get_Char_Index( face, CHARACTER_INDEX);
+            long glyphIndex = FT_Get_Char_Index( face, CHARACTER_CODE_G);
             
-            FT_Set_Char_Size( face, 0L, CHARACTER_SIZE, RESOLUTION, RESOLUTION);
+            FT_Set_Char_Size( face, 0L, GOOD_SIZE, RESOLUTION, RESOLUTION);
             
             error = FT_Load_Glyph( face, glyphIndex, FT_LOAD_DEFAULT);
             assert(!error);
diff --git a/test/FTCharmap-Test.cpp b/test/FTCharmap-Test.cpp
index 2ec3397..5556c9b 100755
--- a/test/FTCharmap-Test.cpp
+++ b/test/FTCharmap-Test.cpp
@@ -7,17 +7,10 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
-#include "FTCharmap.h"
-
-static const unsigned int CHARACTER_CODE      =    'A';
-static const unsigned int BIG_CHARACTER_CODE  = 0x6FB3;
-static const unsigned int NULL_CHARACTER_CODE =    512;
 
-static const unsigned int FONT_INDEX      =   34;
-static const unsigned int BIG_FONT_INDEX  = 4838;
-static const unsigned int NULL_FONT_INDEX =    0;
+#include "Fontdefs.h"
+#include "FTCharmap.h"
 
-static const std::string FONT_FILE = "../../test/MHei-Medium-Acro";
 
 class FTCharmapTest : public CppUnit::TestCase
 {
@@ -67,14 +60,14 @@ class FTCharmapTest : public CppUnit::TestCase
             charmap->CharMap( ft_encoding_unicode);
             
             CPPUNIT_ASSERT( charmap->Error() == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE)      == FONT_INDEX);
+            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A)    == FONT_INDEX_OF_A);
             CPPUNIT_ASSERT( charmap->CharIndex( BIG_CHARACTER_CODE)  == BIG_FONT_INDEX);
             CPPUNIT_ASSERT( charmap->CharIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
             
             charmap->CharMap( ft_encoding_johab);
             
             CPPUNIT_ASSERT( charmap->Error() == 6);
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE)      == FONT_INDEX);
+            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A)    == FONT_INDEX_OF_A);
             CPPUNIT_ASSERT( charmap->CharIndex( BIG_CHARACTER_CODE)  == BIG_FONT_INDEX);
             CPPUNIT_ASSERT( charmap->CharIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
         }
@@ -101,7 +94,7 @@ class FTCharmapTest : public CppUnit::TestCase
         {
             FT_Error error = FT_Init_FreeType( &library);
             assert(!error);
-            error = FT_New_Face( library, FONT_FILE.c_str(), 0, &face);
+            error = FT_New_Face( library, GOOD_FONT_FILE, 0, &face);
             assert(!error);
         }
         
diff --git a/test/FTFace-Test.cpp b/test/FTFace-Test.cpp
index 35c1e1c..300206f 100755
--- a/test/FTFace-Test.cpp
+++ b/test/FTFace-Test.cpp
@@ -3,17 +3,9 @@
 #include "cppunit/TestCase.h"
 #include "cppunit/TestSuite.h"
 
-
+#include "Fontdefs.h"
 #include "FTFace.h"
 
-//#include "arial_ttf.cpp"
-
-
-static const char* BAD_FONT_FILE = "missing_font.ttf";
-static const char* GOOD_FONT_FILE = "../../test/MHei-Medium-Acro";
-
-static const int GOOD_SIZE = 72;
-static const int RESOLUTION = 72;
 
 class FTFaceTest : public CppUnit::TestCase
 {
diff --git a/test/FTFont-Test.cpp b/test/FTFont-Test.cpp
index e2f5cfd..aec9501 100755
--- a/test/FTFont-Test.cpp
+++ b/test/FTFont-Test.cpp
@@ -1,26 +1,13 @@
-#include <iostream>
-
 #include "cppunit/extensions/HelperMacros.h"
 #include "cppunit/TestCaller.h"
 #include "cppunit/TestCase.h"
 #include "cppunit/TestSuite.h"
 
 
+#include "Fontdefs.h"
 #include "FTGlyph.h"
 #include "FTFont.h"
 
-#include "arial_ttf.cpp"
-
-static const char* BAD_FONT_FILE =  "missing_font.ttf";
-static const char* GOOD_FONT_FILE = "../../test/MHei-Medium-Acro";
-
-static const char* GOOD_ASCII_TEST_STRING = "test string";
-static const char* BAD_ASCII_TEST_STRING = "";
-static const wchar_t GOOD_UNICODE_TEST_STRING[4] = { 0x6FB3, 0x9580, 0x0};
-static const wchar_t* BAD_UNICODE_TEST_STRING = L"";
-
-static const unsigned int GOOD_SIZE =  72;
-static const unsigned int RESOLUTION = 72;
 
 class TestGlyph : public FTGlyph
 {
diff --git a/test/FTGlyphContainer-Test.cpp b/test/FTGlyphContainer-Test.cpp
index e91a7be..1f5fba9 100755
--- a/test/FTGlyphContainer-Test.cpp
+++ b/test/FTGlyphContainer-Test.cpp
@@ -3,18 +3,13 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/TestSuite.h>
 
+
+#include "Fontdefs.h"
 #include "FTFace.h"
 #include "FTGlyph.h"
 #include "FTGlyphContainer.h"
 
 
-static const char* GOOD_FONT_FILE = "../../test/MHei-Medium-Acro";
-static const unsigned int NUMBER_OF_GLYPHS = 50;
-static const unsigned int TOO_MANY_GLYPHS = 14100; // MHei-Medium-Acro has 14099
-
-static const unsigned int FONT_INDEX_OF_A = 34;
-
-
 class TestGlyph : public FTGlyph
 {
     public:
diff --git a/test/FTSize-Test.cpp b/test/FTSize-Test.cpp
index 057afbc..cfeb793 100755
--- a/test/FTSize-Test.cpp
+++ b/test/FTSize-Test.cpp
@@ -7,11 +7,9 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
+#include "Fontdefs.h"
 #include "FTSize.h"
 
-static const int CHARACTER_SIZE          = 72;
-static const int RESOLUTION              = 72;
-static const char* FONT_FILE = "../../test/MHei-Medium-Acro";
 
 class FTSizeTest : public CppUnit::TestCase
 {
@@ -47,7 +45,7 @@ class FTSizeTest : public CppUnit::TestCase
             
             FTSize size;
             
-            CPPUNIT_ASSERT( size.CharSize( &face, CHARACTER_SIZE, RESOLUTION, RESOLUTION));
+            CPPUNIT_ASSERT( size.CharSize( &face, GOOD_SIZE, RESOLUTION, RESOLUTION));
             CPPUNIT_ASSERT( size.Error() == 0);
             
             CPPUNIT_ASSERT_DOUBLES_EQUAL(  72, size.CharSize(), 0.01);
@@ -77,7 +75,7 @@ class FTSizeTest : public CppUnit::TestCase
         {
             FT_Error error = FT_Init_FreeType( &library);
             assert(!error);
-            error = FT_New_Face( library, FONT_FILE, 0, &face);
+            error = FT_New_Face( library, GOOD_FONT_FILE, 0, &face);
             assert(!error);
         }
         
diff --git a/test/FTVectoriser-Test.cpp b/test/FTVectoriser-Test.cpp
index 8f40dbb..921ea14 100755
--- a/test/FTVectoriser-Test.cpp
+++ b/test/FTVectoriser-Test.cpp
@@ -3,18 +3,10 @@
 #include <cppunit/TestCase.h>
 #include <cppunit/TestSuite.h>
 
+#include "Fontdefs.h"
 #include "FTVectoriser.h"
 
 
-static const int RESOLUTION = 72;
-static const int CHARACTER_SIZE = 72 * 64;
-
-static const int NULL_CHARACTER_INDEX = ' ';
-static const int SIMPLE_CHARACTER_INDEX = 'i';
-static const int COMPLEX_CHARACTER_INDEX = 'd';
-
-static const char* FONT_FILE = "../../test/arial.ttf";
-
 static double testOutline[] = 
 {
     29, 0, 0.0,
diff --git a/test/Fontdefs.h b/test/Fontdefs.h
new file mode 100644
index 0000000..47daa43
--- /dev/null
+++ b/test/Fontdefs.h
@@ -0,0 +1,36 @@
+#ifndef    __Font_defs__
+#define    __Font_defs__
+
+
+const char* const BAD_FONT_FILE  =  "missing_font.ttf";
+const char* const GOOD_FONT_FILE = "../../test/MHei-Medium-Acro";
+const char* const FONT_FILE      = "../../test/arial.ttf";
+
+const char* const GOOD_ASCII_TEST_STRING        = "test string";
+const char* const BAD_ASCII_TEST_STRING         = "";
+const wchar_t GOOD_UNICODE_TEST_STRING[4] = { 0x6FB3, 0x9580, 0x0};
+const wchar_t* const BAD_UNICODE_TEST_STRING    = L"";
+
+const unsigned int GOOD_SIZE  = 72;
+const unsigned int RESOLUTION = 72;
+const unsigned int CHARACTER_SIZE      = 72 * 64;
+
+const unsigned int CHARACTER_CODE_A        = 'A';
+const unsigned int CHARACTER_CODE_G        = 'g';
+const unsigned int BIG_CHARACTER_CODE      = 0x6FB3;
+const unsigned int NULL_CHARACTER_CODE     = 512;
+const unsigned int NULL_CHARACTER_INDEX    = ' ';
+const unsigned int SIMPLE_CHARACTER_INDEX  = 'i';
+const unsigned int COMPLEX_CHARACTER_INDEX = 'd';
+
+const unsigned int FONT_INDEX_OF_A = 34;
+const unsigned int BIG_FONT_INDEX  = 4838;
+const unsigned int NULL_FONT_INDEX = 0;
+
+const unsigned int NUMBER_OF_GLYPHS = 50;
+const unsigned int TOO_MANY_GLYPHS  = 14100; // MHei-Medium-Acro has 14099
+
+
+#include "arial_ttf.cpp"
+
+#endif // __Font_defs__
\ No newline at end of file
diff --git a/test/arial_ttf.cpp b/test/arial_ttf.cpp
index 39efbdf..3bca786 100755
--- a/test/arial_ttf.cpp
+++ b/test/arial_ttf.cpp
@@ -10,14 +10,14 @@
 
 // TODO: could add a version number to the struct
 typedef struct BINARYFILEDUMP_struct {
-	unsigned char * dataBytes;
+	const unsigned char * dataBytes;
 	size_t numBytes;
 } BINARYFILEDUMP;
 #endif
 
 #endif
 
-unsigned char byte_data_arial_ttf[ ] =
+const unsigned char byte_data_arial_ttf[ ] =
 {
 	0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x01, 0x00, 0x00, 0x04, 0x00, 0x30, 0x4c, 0x54, 0x53, 0x48, 0x59, 0xbf, 0xc8, 0x0f, 0x00, 0x00, 0x01, 0x3c, 0x00, 0x00, 0x02, 0x91, 0x4f, 0x53, 0x2f, 0x32, 0x93, 0x76, 0x8d, 0x49, 0x00, 0x02, 0x2f, 0x6c, 0x00, 0x00, 0x00, 0x56, 0x50, 0x43, 0x4c, 0x54, 0xfd, 0x7b, 0x3e, 0x43, 0x00, 0x00, 0x03, 0xd0, 0x00, 0x00, 0x00, 0x36, 0x56, 0x44, 0x4d, 0x58, 0x50, 0x92, 0x6a, 0xf5, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x11, 0x94, 0x63, 0x6d, 0x61, 0x70, 0x54, 0xb0, 0xc8, 0x5f, 0x00, 0x00, 0x15, 0x9c, 0x00, 0x00, 0x06, 0xb6, 0x63, 0x76, 0x74, 0x20, 0x7b, 0x2a, 0x9d, 0x31, 0x00, 0x00, 0x1c, 0x54, 0x00, 0x00, 0x05, 0x88, 0x66, 0x70, 0x67, 0x6d, 0x77, 0x27, 0xa9, 0xf5, 0x00, 0x00, 0x21, 0xdc, 0x00, 0x00, 0x05, 0xb0, 0x67, 0x61, 0x73, 0x70, 0x00, 0x18, 0x00, 0x09, 0x00, 0x00, 0x27, 0x8c, 0x00, 0x00, 0x00, 0x10, 0x67, 0x6c, 0x79, 0x66, 0xac, 0x24, 0xc3, 0xa7, 0x00, 0x00, 0x27, 0x9c, 0x00, 0x01, 0x83, 0x6c, 0x68, 0x64, 0x6d, 0x78, 0x3b, 0x27, 0x6d, 0x02, 0x00, 0x01, 0xab, 0x08, 0x00, 0x00, 0x3d, 0x88, 0x68, 0x65, 0x61, 0x64, 0xb1, 0x1f, 0xd8, 0x1d, 0x00, 0x01, 0xe8, 0x90, 0x00, 0x00, 0x00, 0x36, 0x68, 0x68, 0x65, 0x61, 0x0e, 0x50, 0x07, 0xcf, 0x00, 0x01, 0xe8, 0xc8, 0x00, 0x00, 0x00, 0x24, 0x68, 0x6d, 0x74, 0x78, 0x03, 0xe7, 0xf2, 0x62, 0x00, 0x01, 0xe8, 0xec, 0x00, 0x00, 0x0a, 0x34, 0x6b, 0x65, 0x72, 0x6e, 0x37, 0x61, 0x39, 0x36, 0x00, 0x01, 0xf3, 0x20, 0x00, 0x00, 0x15, 0x60, 0x6c, 0x6f, 0x63, 0x61, 0x4f, 0x5f, 0xaf, 0x9c, 0x00, 0x02, 0x08, 0x80, 0x00, 0x00, 0x05, 0x1c, 0x6d, 0x61, 0x78, 0x70, 
 	0x05, 0xca, 0x09, 0x81, 0x00, 0x02, 0x0d, 0x9c, 0x00, 0x00, 0x00, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x16, 0xdc, 0x38, 0xec, 0x00, 0x02, 0x0d, 0xbc, 0x00, 0x00, 0x06, 0xb5, 0x70, 0x6f, 0x73, 0x74, 0x63, 0xfa, 0x87, 0xa8, 0x00, 0x02, 0x14, 0x74, 0x00, 0x00, 0x12, 0xe4, 0x70, 0x72, 0x65, 0x70, 0x56, 0x44, 0xee, 0xa0, 0x00, 0x02, 0x27, 0x58, 0x00, 0x00, 0x08, 0x13, 0x00, 0x00, 0x02, 0x8d, 0x07, 0x01, 0x01, 0x01, 0xab, 0x06, 0x06, 0x06, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x01, 0x25, 0x05, 0x0c, 0x0c, 0x0c, 0x0c, 0x12, 0x1c, 0x3e, 0x1c, 0x05, 0x06, 0x75, 0x1c, 0x12, 0x1c, 0x12, 0x12, 0x05, 0x9a, 0x1c, 0x1f, 0x85, 0xe0, 0x96, 0x12, 0x07, 0x07, 0x07, 0xc2, 0x06, 0x06, 0x26, 0x35, 0x06, 0x23, 0x27, 0x65, 0x53, 0x37, 0x39, 0xe5, 0x5d, 0x39, 0x71, 0x37, 0x24, 0x35, 0x53, 0x06, 0x2b, 0x12, 0x37, 0xc6, 0xa4, 0xd5, 0xc4, 0x63, 0x06, 0xfe, 0x06, 0x07, 0x05, 0x05, 0x06, 0x05, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x11, 0x06, 0x06, 0x01, 0x06, 0x06, 0x06, 0x01, 0x0c, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 0x0c, 0x0c, 0x01, 0x06, 0xff, 0x16, 0x18, 0x01, 0x05, 0x29, 0x0c, 0xe1, 0x07, 0x52, 0x06, 0x0c, 0x4d, 0x06, 0x06, 0x01, 0x05, 0x05, 0x07, 0x11, 0x07, 0x06, 0x01, 0x14, 0x14, 0x05, 0x05, 0x06, 0x02, 0x06, 0x05, 0x01, 0x0c, 0x06, 0x07, 0x01, 
@@ -584,7 +584,7 @@ unsigned char byte_data_arial_ttf[ ] =
 // WARNING: this won't work in a pure C compiler?
 const int byte_size_arial_ttf = 143300;
 
-BINARYFILEDUMP arial_ttf =
+BINARYFILEDUMP const arial_ttf =
 {
 	// Filename: "arial.ttf"
 	byte_data_arial_ttf,