On Sat, Jul 12, 2008 at 4:35 PM, Nikolay Sivov bunglehead@gmail.com wrote:
James Hawkins wrote:
On Sat, Jul 12, 2008 at 4:12 PM, Nikolay Sivov bunglehead@gmail.com wrote:
Changelog:
- Make GdipInvertMatrix test pass on native
dlls/gdiplus/tests/matrix.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/tests/matrix.c b/dlls/gdiplus/tests/matrix.c index 16c1517..daf61ea 100644 --- a/dlls/gdiplus/tests/matrix.c +++ b/dlls/gdiplus/tests/matrix.c @@ -27,6 +27,19 @@
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
+/* compare matrix data with some tolerance */ +BOOL m_equalf(REAL *m1, REAL *m2) +{
- BOOL ret = TRUE;
- INT i;
- for(i = 0; i < 6; i++){
ret = ret && (fabsf(m1[i] - m2[i]) < 1e-5);
- }
- return ret;
+}
static void test_constructor_destructor(void) { GpStatus status; @@ -119,12 +132,12 @@ static void test_isinvertible(void) GdipDeleteMatrix(matrix); }
+static REAL minverted[] = {1.0/9.0, 2.0/9.0, 4.0/9.0, -1.0/9.0, -2.0, -1.0}; static void test_invert(void) { GpStatus status; GpMatrix *matrix = NULL;
- GpMatrix *inverted = NULL;
- BOOL equal;
REAL mdata[6];
/* NULL */ status = GdipInvertMatrix(NULL);
@@ -141,11 +154,9 @@ static void test_invert(void) status = GdipInvertMatrix(matrix); expect(Ok, status);
- GdipCreateMatrix2(1.0/9.0, 2.0/9.0, 4.0/9.0, -1.0/9.0, -2.0, -1.0,
&inverted);
- GdipIsMatrixEqual(matrix, inverted, &equal);
- expect(TRUE, equal);
- GdipGetMatrixElements(matrix, mdata);
- expect(TRUE, m_equalf(mdata, minverted));
Why are you creating a new function that allows tolerance when you control the matrix you're comparing it to? Allowing slop is acceptable in some circumstances, but not in this case, when there is one exact value (or matrix of values) returned.
Of course there's only one value of inverted matrix. GDI+ uses floating point values for matrix elements so don't you think the result could be slightly different due different calculation algorithms?
If you write and test the results in Windows, you won't have to guess what the results will be. No I don't think the results will be slightly different. Higher-precision arithmetic doesn't mean more slop.