File: FTContour-Test.cpp

package info (click to toggle)
mysql-query-browser 1.2.5beta-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 63,792 kB
  • ctags: 46,485
  • sloc: pascal: 249,299; ansic: 80,111; cpp: 72,467; sh: 25,271; objc: 20,015; yacc: 10,755; java: 9,917; xml: 4,580; php: 2,806; python: 1,566; sql: 1,563; makefile: 1,452; perl: 3
file content (226 lines) | stat: -rw-r--r-- 4,517 bytes parent folder | download | duplicates (8)
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>

#include "FTContour.h"

// FT_Curve_Tag_On           1
// FT_Curve_Tag_Conic        0
// FT_Curve_Tag_Cubic        2

static FT_Vector shortLine[2] =
{
    { 1, 1},
    { 2, 2},
};

static FT_Vector straightLinePoints[3] = 
{
    { 0,  0},
    { 6,  7},
    { 9, -2}
};

static char straightLineTags[3] =
{
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_On
};

static char brokenTags[3] =
{
    FT_Curve_Tag_Conic,
    69,
    FT_Curve_Tag_On
};

static FT_Vector simpleConicPoints[3] = 
{
    { 0,  0},
    { 6,  7},
    { 9, -2}
};

static FT_Vector brokenPoints[3] = 
{
    { 0, 0},
    { 0, 0},
    { 0, 0}
};

static char simpleConicTags[3] = 
{
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_On,
    FT_Curve_Tag_On
};

static FT_Vector doubleConicPoints[4] = 
{
    { 0,  0},
    { 6,  7},
    { 9, -2},
    { 4,  0}
};

static char doubleConicTags[4] = 
{
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic
};

static FT_Vector cubicPoints[4] = 
{
    { 0,  0},
    { 6,  7},
    { 9, -2},
    { 4,  0}
};

static char cubicTags[4] = 
{
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Cubic,
    FT_Curve_Tag_Cubic
};


// ARIAl 'd'
static FT_Vector compositePoints[18] = 
{
	{ 1856,    0},
	{ 1856,  279},
	{ 1625,  -64},
	{ 1175,  -64},
	{  884,  -64},
	{  396,  251},
	{  128,  815},
	{  128, 1182},
	{  128, 1539},
	{  370, 2121},
	{  855, 2432},
	{ 1156, 2432},
	{ 1375, 2432},
	{ 1718, 2257},
	{ 1826, 2118},
	{ 1826, 3264},
	{ 2240, 3264},
	{ 2240,    0},
};

static char compositeTags[18] = 
{
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_On,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_Conic,
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_On,
    FT_Curve_Tag_On
};

class FTContourTest : public CppUnit::TestCase
{
    CPPUNIT_TEST_SUITE( FTContourTest);
        CPPUNIT_TEST( testNullCurve);
        CPPUNIT_TEST( testBrokenCurve);
        CPPUNIT_TEST( testStraightLine);
        CPPUNIT_TEST( testConicCurve);
        CPPUNIT_TEST( testDoubleConicCurve);
        CPPUNIT_TEST( testCubicCurve);
        CPPUNIT_TEST( testCompositeCurve);
    CPPUNIT_TEST_SUITE_END();
        
    public:
        FTContourTest() : CppUnit::TestCase( "FTContour Test")
        {}
        
        FTContourTest( const std::string& name) : CppUnit::TestCase(name)
        {}

        void testNullCurve()
        {
            FTContour contour( NULL, NULL, 0);
            CPPUNIT_ASSERT( contour.PointCount() == 0);
        }


        void testBrokenCurve()
        {
            FTContour contour( brokenPoints, simpleConicTags, 3);
            CPPUNIT_ASSERT( contour.PointCount() == 1);

            FTContour shortContour( shortLine, simpleConicTags, 2);
            CPPUNIT_ASSERT( shortContour.PointCount() == 6);

            FTContour reallyShortContour( shortLine, simpleConicTags, 1);
            CPPUNIT_ASSERT( reallyShortContour.PointCount() == 1);

            FTContour brokenTagtContour( shortLine, brokenTags, 3);
            CPPUNIT_ASSERT( brokenTagtContour.PointCount() == 7);
        }


        void testStraightLine()
        {
            FTContour contour( straightLinePoints, straightLineTags, 3);
            CPPUNIT_ASSERT( contour.PointCount() == 3);
        }


        void testConicCurve()
        {
            FTContour contour( simpleConicPoints, simpleConicTags, 3);
            CPPUNIT_ASSERT( contour.PointCount() == 7);
        }


        void testDoubleConicCurve()
        {
            FTContour contour( doubleConicPoints, doubleConicTags, 4);
            CPPUNIT_ASSERT( contour.PointCount() == 12);
        }


        void testCubicCurve()
        {
            FTContour contour( cubicPoints, cubicTags, 4);
            CPPUNIT_ASSERT( contour.PointCount() == 7);
        }


        void testCompositeCurve()
        {
            FTContour contour( compositePoints, compositeTags, 18);
            CPPUNIT_ASSERT( contour.PointCount() == 50);
        }
        
        
        void setUp() 
        {}
        
        
        void tearDown() 
        {}
        
    private:
};

CPPUNIT_TEST_SUITE_REGISTRATION( FTContourTest);