summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2021-08-26 22:40:15 +0700
committerPierre Joye <pierre.php@gmail.com>2021-08-26 22:40:15 +0700
commit13d3b67822f9e8b2f6cfc96933abeef054d37085 (patch)
treeec7383b9e604691603727ea5b786dfb2bbba9d58 /tests
parent63070b49e2f7380b11bf8d2f6f8cdf49cbe8076d (diff)
downloadlibgd-13d3b67822f9e8b2f6cfc96933abeef054d37085.tar.gz
Fix #402, negative determinant fails, only 0 or not finite should fail
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/gdmatrix/CMakeLists.txt5
-rw-r--r--tests/gdmatrix/bug00402.c30
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 51f09c4..25a19ba 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -78,6 +78,7 @@ if (BUILD_TEST)
gdimagestringup16
gdimagetruecolortopalette
gdinterpolatedscale
+ gdmatrix
gdnewfilectx
gdtest
gdtiled
diff --git a/tests/gdmatrix/CMakeLists.txt b/tests/gdmatrix/CMakeLists.txt
new file mode 100644
index 0000000..1035246
--- /dev/null
+++ b/tests/gdmatrix/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ bug00402
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdmatrix/bug00402.c b/tests/gdmatrix/bug00402.c
new file mode 100644
index 0000000..15529b6
--- /dev/null
+++ b/tests/gdmatrix/bug00402.c
@@ -0,0 +1,30 @@
+#include "gd.h"
+#include <stdio.h>
+#include "gdtest.h"
+#include <math.h>
+int main()
+{
+ double matrix[6] = {
+ 0.000000, 0.150000,
+ 0.150000, -0.000000,
+ 0.000000, 0.000000
+ };
+ double matrix_inv[6];
+ double matrix_inv_exp[6] = {
+ 0.0000000000, 6.6666666667,
+ 6.6666666667, -0.0000000000,
+ -0.0000000000, 0.0000000000
+ };
+
+ int res = gdAffineInvert(matrix_inv, matrix);
+
+ for (int i=0; i < 6; i++) {
+ double rounded_res = round(matrix_inv[i] * 10);
+ double rounded_exp = round(matrix_inv_exp[i] * 10);
+ if (rounded_res != rounded_exp) {
+ printf("%i failed %f exp %f", i, matrix_inv[i], matrix_inv_exp[i]);
+ return -1;
+ }
+ }
+ return res;
+}