2 * Unit test suite for matrices
4 * Copyright (C) 2007 Google (Evan Stade)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
27 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
29 static void test_constructor_destructor(void)
32 GpMatrix
*matrix
= NULL
;
34 status
= GdipCreateMatrix2(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &matrix
);
36 ok(matrix
!= NULL
, "Expected matrix to be initialized\n");
38 status
= GdipDeleteMatrix(NULL
);
39 expect(InvalidParameter
, status
);
41 status
= GdipDeleteMatrix(matrix
);
50 static real_point transform_points
[] = {
51 {1000.00, 2600.00}, /*0*/
52 {855.00, 2390.00}, /*1*/
53 {700.00, 2200.00}, /*2*/
54 {565.00, 1970.00}, /*3*/
55 {400.00, 1800.00}, /*4*/
56 {275.00, 1550.00}, /*5*/
57 {100.00, 1400.00}, /*6*/
58 {-15.00, 1130.00}, /*7*/
59 {-200.00, 1000.00}, /*8*/
60 {-305.00, 710.00} /*9*/
63 static void test_transform(void)
66 GpMatrix
*matrix
= NULL
;
71 for(i
= 0; i
< 10; i
++){
72 pts
[i
].X
= i
* 5.0 * (REAL
)(i
% 2);
73 pts
[i
].Y
= 50.0 - i
* 5.0;
76 GdipCreateMatrix2(1.0, -2.0, 30.0, 40.0, -500.0, 600.0, &matrix
);
78 status
= GdipTransformMatrixPoints(matrix
, pts
, 10);
81 for(i
= 0; i
< 10; i
++){
82 match
= fabs(transform_points
[i
].X
- pts
[i
].X
) < 2.0
83 && fabs(transform_points
[i
].Y
- pts
[i
].Y
) < 2.0;
85 ok(match
, "Expected #%d to be (%.2f, %.2f) but got (%.2f, %.2f)\n", i
,
86 transform_points
[i
].X
, transform_points
[i
].Y
, pts
[i
].X
, pts
[i
].Y
);
89 GdipDeleteMatrix(matrix
);
94 struct GdiplusStartupInput gdiplusStartupInput
;
95 ULONG_PTR gdiplusToken
;
97 gdiplusStartupInput
.GdiplusVersion
= 1;
98 gdiplusStartupInput
.DebugEventCallback
= NULL
;
99 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
100 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
102 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
104 test_constructor_destructor();
107 GdiplusShutdown(gdiplusToken
);