1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for ...
5  * PROGRAMMERS:     Timo Kreuzer
6  *                  Katayama Hirofumi MZ
7  */
8 
9 #include "precomp.h"
10 
11 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
12 #define NO_CHECK 0xFACECAFE
13 #define CALC_VALUE_1 0xBADACE01
14 #define CALC_VALUE_2 0xFEEDF00D
15 #define CALC_VALUE_3 0xDEADCAD1
16 #define DISPLAY_SIZE 0xDEADBEEF
17 #define NEGA_DISPLAY_SIZE 0xBEEFDEAD
18 
19 typedef struct PRESET
20 {
21     LONG xWnd;
22     LONG yWnd;
23     LONG cxWnd;
24     LONG cyWnd;
25 
26     LONG xView;
27     LONG yView;
28     LONG cxView;
29     LONG cyView;
30 } PRESET;
31 
32 typedef struct TEST_ENTRY
33 {
34     INT lineno;
35     BOOL ret;
36     DWORD error;
37 
38     BOOL bWndExt;
39     INT nMapMode;
40 
41     PRESET preset;
42 
43     LONG xWndOut;
44     LONG yWndOut;
45     LONG cxWndOut;
46     LONG cyWndOut;
47 
48     LONG xViewOut;
49     LONG yViewOut;
50     LONG cxViewOut;
51     LONG cyViewOut;
52 
53     POINT ptSrc;
54     POINT ptDest;
55 } TEST_ENTRY;
56 
57 #define PRESET0     { 0,  0,   0,   0,   0,   0,  0,    0   }
58 #define PRESET1     { 0,  0,   1,   1,   0,   0,  1,    1   }
59 #define PRESET2     { 75, 0,   1,   1,   0,   0,  10,   10  }
60 #define PRESET3     { 0,  180, 1,   1,   120, 0,  1,    1   }
61 #define PRESET4     { 0,  0,   200, 1,   50,  0,  1,    1   }
62 #define PRESET5     { 0,  0,   1,   200, 0,   0,  -100, 1   }
63 #define PRESET6     { 50, 0,   1,   200, 10,  0,  100,  200 }
64 
65 static const TEST_ENTRY s_entries[] =
66 {
67     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET0, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 100, 150 } },
68     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 100, 150 } },
69     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET2, 75, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 175, 150 } },
70     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { -20, 330 } },
71     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET4, 0, 0, 1, 1, 50, 0, 1, 1, { 100, 150 }, { 50, 150 } },
72     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET5, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 100, 150 } },
73     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET6, 50, 0, 1, 1, 10, 0, 1, 1, { 100, 150 }, { 140, 150 } },
74 
75     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ANISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { NO_CHECK, NO_CHECK } },
76     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 100, 150 } },
77     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { 85, 15 } },
78     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { -20, 330 } },
79     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 1, { 100, 150 }, { 10000, 150 } },
80     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, -100, 1, { 100, 150 }, { -1, 30000 } },
81     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 100, 200, { 100, 150 }, { 51, 150 } },
82 
83     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { NO_CHECK, NO_CHECK } },
84     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { 100, 150 } },
85     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { 85, 15 } },
86     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { -20, 330 } },
87     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 0, { 100, 150 }, { 100, 150 } },
88     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, 0, 1, { 100, 150 }, { 100, 150 } },
89     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 1, 200, { 100, 150 }, { 140, 150 } },
90 
91     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
92     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
93     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
94     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
95     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
96     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
97     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
98 
99     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
100     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
101     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
102     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
103     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
104     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
105     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
106 
107     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
108     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
109     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
110     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
111     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
112     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
113     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
114 
115     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
116     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
117     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
118     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
119     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
120     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
121     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
122 
123     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
124     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
125     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
126     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
127     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
128     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
129     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_1 , CALC_VALUE_1 } },
130 };
131 static const size_t s_entries_count = _countof(s_entries);
132 
133 static const TEST_ENTRY s_shifted_entries[] =
134 {
135     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET0, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
136     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
137     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET2, 75, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
138     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
139     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET4, 0, 0, 1, 1, 50, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
140     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET5, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
141     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET6, 50, 0, 1, 1, 10, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
142 
143     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ANISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { NO_CHECK, NO_CHECK } },
144     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
145     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
146     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
147     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
148     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, -100, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
149     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 100, 200, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
150 
151     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { NO_CHECK, NO_CHECK } },
152     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
153     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
154     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
155     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 0, { 100, 150 }, { 100, 150 } },
156     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, 0, 1, { 100, 150 }, { 100, 150 } },
157     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 1, 200, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
158 
159     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
160     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
161     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
162     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
163     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
164     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
165     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
166 
167     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
168     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
169     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
170     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
171     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
172     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
173     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
174 
175     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
176     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
177     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
178     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
179     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
180     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
181     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
182 
183     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
184     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
185     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
186     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
187     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
188     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
189     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
190 
191     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
192     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
193     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
194     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
195     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
196     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
197     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_2, CALC_VALUE_2 } },
198 };
199 static const size_t s_shifted_entries_count = _countof(s_shifted_entries);
200 
201 static const TEST_ENTRY s_transformed_entries[] =
202 {
203     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET0, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
204     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
205     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET2, 75, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
206     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
207     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET4, 0, 0, 1, 1, 50, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
208     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET5, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
209     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TEXT, PRESET6, 50, 0, 1, 1, 10, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
210 
211     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ANISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
212     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
213     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
214     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
215     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
216     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, -100, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
217     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ANISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 100, 200, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
218 
219     { __LINE__, TRUE, 0xDEADBEEF, FALSE, MM_ISOTROPIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, NO_CHECK, NO_CHECK, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
220     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET1, 0, 0, 1, 1, 0, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
221     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET2, 75, 0, 1, 1, 0, 0, 10, 10, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
222     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET3, 0, 180, 1, 1, 120, 0, 1, 1, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
223     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET4, 0, 0, 200, 1, 50, 0, 1, 0, { 100, 150 }, { 100, 150 } },
224     { __LINE__, FALSE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET5, 0, 0, 1, 200, 0, 0, 0, 1, { 100, 150 }, { 100, 150 } },
225     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_ISOTROPIC, PRESET6, 50, 0, 1, 200, 10, 0, 1, 200, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
226 
227     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
228     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
229     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
230     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
231     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
232     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
233     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
234 
235     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
236     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
237     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
238     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
239     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
240     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
241     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIMETRIC, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
242 
243     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
244     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
245     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
246     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
247     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
248     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
249     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_LOENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
250 
251     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
252     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
253     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
254     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
255     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
256     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
257     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_HIENGLISH, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
258 
259     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET0, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
260     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET1, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
261     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET2, 75, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
262     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET3, 0, 180, NO_CHECK, NO_CHECK, 120, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
263     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET4, 0, 0, NO_CHECK, NO_CHECK, 50, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
264     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET5, 0, 0, NO_CHECK, NO_CHECK, 0, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
265     { __LINE__, TRUE, 0xDEADBEEF, TRUE, MM_TWIPS, PRESET6, 50, 0, NO_CHECK, NO_CHECK, 10, 0, DISPLAY_SIZE, NEGA_DISPLAY_SIZE, { 100, 150 }, { CALC_VALUE_3, CALC_VALUE_3 } },
266 };
267 static const size_t s_transformed_entries_count = _countof(s_transformed_entries);
268 
269 static void SetXForm1(XFORM *pxform)
270 {
271     pxform->eM11 = 1;
272     pxform->eM12 = 0;
273     pxform->eM21 = 0;
274     pxform->eM22 = 1;
275     pxform->eDx = 314;
276     pxform->eDy = -99;
277 }
278 
279 static void SetXForm2(XFORM *pxform)
280 {
281     pxform->eM11 = 2;
282     pxform->eM12 = 0;
283     pxform->eM21 = 0;
284     pxform->eM22 = 3;
285     pxform->eDx = 0;
286     pxform->eDy = 0;
287 }
288 
289 static BOOL InverseXForm(XFORM *pxform)
290 {
291     XFORM xform = *pxform;
292     FLOAT delta = xform.eM11 * xform.eM22 - xform.eM12 * xform.eM21;
293     if (delta == 0)
294         return FALSE;
295 
296     pxform->eM11 = xform.eM22 / delta;
297     pxform->eM12 = -xform.eM12 / delta;
298     pxform->eM21 = -xform.eM21 / delta;
299     pxform->eM22 = xform.eM11 / delta;
300     pxform->eDx = (-xform.eM22 * xform.eDx + xform.eM12 * xform.eDy);
301     pxform->eDy = (xform.eM21 * xform.eDx - xform.eM11 * xform.eDy);
302     return TRUE;
303 }
304 
305 static void DoTestEntry(HDC hDC, const TEST_ENTRY *entry)
306 {
307     POINT pt, ptWnd, ptView;
308     SIZE siz, sizWnd, sizView;
309     INT ret;
310 
311     SetMapMode(hDC, entry->nMapMode);
312 
313     ret = SetWindowOrgEx(hDC, entry->preset.xWnd, entry->preset.yWnd, NULL);
314     ok(ret == TRUE, "Line %d: SetWindowOrgEx failed\n", entry->lineno);
315 
316     ret = SetWindowExtEx(hDC, entry->preset.cxWnd, entry->preset.cyWnd, NULL);
317     ok(ret == entry->bWndExt, "Line %d: SetWindowExtEx() expected %d, was %d\n", entry->lineno, entry->bWndExt, ret);
318 
319     ret = SetViewportOrgEx(hDC, entry->preset.xView, entry->preset.yView, NULL);
320     ok(ret == TRUE, "Line %d: SetViewportOrgEx failed\n", entry->lineno);
321 
322     ret = SetViewportExtEx(hDC, entry->preset.cxView, entry->preset.cyView, NULL);
323     ok(ret == TRUE, "Line %d: SetViewportExtEx failed\n", entry->lineno);
324 
325     ok(GetWindowOrgEx(hDC, &pt) == TRUE, "Line %d: GetWindowOrgEx failed\n", entry->lineno);
326     ptWnd = pt;
327     ok(GetWindowExtEx(hDC, &siz) == TRUE, "Line %d: GetWindowExtEx failed\n", entry->lineno);
328     sizWnd = siz;
329 
330     ok(pt.x == entry->xWndOut && pt.y == entry->yWndOut,
331        "Line %d: Window org expected (%ld, %ld), was (%ld, %ld)\n",
332         entry->lineno, entry->xWndOut, entry->yWndOut, pt.x, pt.y);
333 
334     if (entry->cxWndOut == DISPLAY_SIZE || entry->cxWndOut == NEGA_DISPLAY_SIZE)
335     {
336         LONG cx = GetDeviceCaps(hDC, HORZRES);
337         LONG cy = GetDeviceCaps(hDC, VERTRES);
338         if (entry->cxWndOut == NEGA_DISPLAY_SIZE)
339             cx = -cx;
340         if (entry->cyWndOut == NEGA_DISPLAY_SIZE)
341             cy = -cy;
342         ok(siz.cx == cx && siz.cy == cy,
343            "Line %d: Window ext expected display size (%ld, %ld), was (%ld, %ld)\n",
344             entry->lineno, cx, cy, siz.cx, siz.cy);
345     }
346     else if (entry->cxWndOut != NO_CHECK)
347     {
348         ok(siz.cx == entry->cxWndOut && siz.cy == entry->cyWndOut,
349            "Line %d: Window ext expected (%ld, %ld), was (%ld, %ld)\n",
350             entry->lineno, entry->cxWndOut, entry->cyWndOut, siz.cx, siz.cy);
351     }
352 
353     ok(GetViewportOrgEx(hDC, &pt) == TRUE, "Line %d: GetViewportOrgEx failed\n", entry->lineno);
354     ptView = pt;
355     ok(GetViewportExtEx(hDC, &siz) == TRUE, "Line %d: GetViewportExtEx failed\n", entry->lineno);
356     sizView = siz;
357 
358     ok(pt.x == entry->xViewOut && pt.y == entry->yViewOut,
359        "Line %d: Viewport org expected (%ld, %ld), was (%ld, %ld)\n",
360         entry->lineno, entry->xViewOut , entry->yViewOut, pt.x, pt.y);
361 
362     if (entry->cxViewOut == DISPLAY_SIZE || entry->cxViewOut == NEGA_DISPLAY_SIZE)
363     {
364         LONG cx = GetDeviceCaps(hDC, HORZRES);
365         LONG cy = GetDeviceCaps(hDC, VERTRES);
366         if (entry->cxViewOut == NEGA_DISPLAY_SIZE)
367             cx = -cx;
368         if (entry->cyViewOut == NEGA_DISPLAY_SIZE)
369             cy = -cy;
370         ok(siz.cx == cx && siz.cy == cy,
371            "Line %d: Viewport ext expected display size (%ld, %ld), was (%ld, %ld)\n",
372             entry->lineno, cx, cy, siz.cx, siz.cy);
373     }
374     else if (entry->cxViewOut != NO_CHECK)
375     {
376         ok(siz.cx == entry->cxViewOut && siz.cy == entry->cyViewOut,
377            "Line %d: Viewport ext expected (%ld, %ld), was (%ld, %ld)\n",
378             entry->lineno, entry->cxViewOut, entry->cyViewOut, siz.cx, siz.cy);
379     }
380 
381     pt = entry->ptSrc;
382 
383     SetLastError(0xDEADBEEF);
384     ret = DPtoLP(hDC, &pt, 1);
385     ok(ret == entry->ret, "Line %d: DPtoLP() expected %d, was %d\n", entry->lineno, entry->ret, ret);
386 
387     ok(GetLastError() == entry->error, "Line %d: GetLastError() expected %ld, was %ld\n",
388        entry->lineno, entry->error, GetLastError());
389 
390     if (entry->ptDest.x == CALC_VALUE_1)
391     {
392         LONG x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
393         LONG y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
394         // TODO: make more accurate
395         ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
396            "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
397            entry->lineno, x, y, pt.x, pt.y);
398     }
399     else if (entry->ptDest.x == CALC_VALUE_2)
400     {
401         XFORM xform;
402         LONG x, y;
403         SetXForm1(&xform);
404         if (InverseXForm(&xform))
405         {
406             x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
407             y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
408             x = (LONG)((xform.eM11 * x + xform.eM12 * y) + xform.eDx);
409             y = (LONG)((xform.eM21 * x + xform.eM22 * y) + xform.eDy);
410             // TODO: make more accurate
411             ok(labs(pt.x - x) <= 1 && labs(pt.y - y) <= 1,
412                "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
413                entry->lineno, x, y, pt.x, pt.y);
414         }
415     }
416     else if (entry->ptDest.x == CALC_VALUE_3)
417     {
418         XFORM xform;
419         LONG x, y;
420         SetXForm2(&xform);
421         if (InverseXForm(&xform))
422         {
423             x = MulDiv(entry->ptSrc.x - ptView.x, sizWnd.cx, sizView.cx) + ptWnd.x;
424             y = MulDiv(entry->ptSrc.y - ptView.y, sizWnd.cy, sizView.cy) + ptWnd.y;
425             x = (LONG)((xform.eM11 * x + xform.eM12 * y) + xform.eDx);
426             y = (LONG)((xform.eM21 * x + xform.eM22 * y) + xform.eDy);
427             // TODO: make more accurate
428             ok(labs(pt.x - x) <= 2 && labs(pt.y - y) <= 2,
429                "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
430                entry->lineno, x, y, pt.x, pt.y);
431         }
432     }
433     else if (entry->ptDest.x != NO_CHECK)
434     {
435         ok(pt.x == entry->ptDest.x && pt.y == entry->ptDest.y,
436            "Line %d: Dest expected (%ld, %ld), was (%ld, %ld)\n",
437            entry->lineno, entry->ptDest.x, entry->ptDest.y, pt.x, pt.y);
438     }
439 }
440 
441 START_TEST(DPtoLP)
442 {
443     size_t i;
444     POINT apt[2];
445     XFORM xform;
446 
447     HDC hDC = CreateCompatibleDC(NULL);
448     ok(hDC != NULL, "hDC is NULL\n");
449 
450     SetLastError(0xDEADBEEF);
451     ok_int(DPtoLP(NULL, NULL, 0), 1);
452     ok_err(0xDEADBEEF);
453 
454     ok_int(DPtoLP(NULL, NULL, -1), 1);
455     ok_err(0xDEADBEEF);
456 
457     ok_int(DPtoLP(NULL, INVALID_POINTER, -1), 1);
458     ok_err(0xDEADBEEF);
459 
460     ok_int(DPtoLP(NULL, NULL, 2), 0);
461     ok_err(ERROR_INVALID_PARAMETER);
462 
463     SetLastError(0xDEADBEEF);
464     ok_int(DPtoLP(NULL, apt, 2), 0);
465     ok_err(ERROR_INVALID_PARAMETER);
466 
467     SetLastError(0xDEADBEEF);
468     ok_int(DPtoLP(NULL, apt, 0), 1);
469     ok_err(0xDEADBEEF);
470 
471     SetLastError(0xDEADBEEF);
472     ok_int(DPtoLP(NULL, apt, -2), 1);
473     ok_err(0xDEADBEEF);
474 
475     SetLastError(0xDEADBEEF);
476     ok_int(DPtoLP((HDC)-4, apt, -2), 1);
477     ok_err(0xDEADBEEF);
478 
479     SetLastError(0xDEADBEEF);
480     ok_int(DPtoLP(hDC, NULL, 2), 1);
481     ok_err(0xDEADBEEF);
482 
483     SetLastError(0xDEADBEEF);
484     ok_int(DPtoLP(hDC, INVALID_POINTER, 2), 1);
485     ok_err(0xDEADBEEF);
486 
487     SetGraphicsMode(hDC, GM_COMPATIBLE);
488     ModifyWorldTransform(hDC, NULL, MWT_IDENTITY);
489 
490     for (i = 0; i < s_entries_count; ++i)
491     {
492         DoTestEntry(hDC, &s_entries[i]);
493     }
494 
495     SetGraphicsMode(hDC, GM_ADVANCED);
496     ModifyWorldTransform(hDC, NULL, MWT_IDENTITY);
497 
498     for (i = 0; i < s_entries_count; ++i)
499     {
500         DoTestEntry(hDC, &s_entries[i]);
501     }
502 
503     SetXForm1(&xform);
504     SetGraphicsMode(hDC, GM_ADVANCED);
505     SetWorldTransform(hDC, &xform);
506     for (i = 0; i < s_shifted_entries_count; ++i)
507     {
508         DoTestEntry(hDC, &s_shifted_entries[i]);
509     }
510 
511     SetXForm2(&xform);
512     SetGraphicsMode(hDC, GM_ADVANCED);
513     SetWorldTransform(hDC, &xform);
514     for (i = 0; i < s_transformed_entries_count; ++i)
515     {
516         DoTestEntry(hDC, &s_transformed_entries[i]);
517     }
518 
519     DeleteDC(hDC);
520 }
521