summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2021-03-16 14:31:20 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2021-03-16 14:31:20 +0200
commita9ab7a62e23f8ec6bb1b1ee2da754dddd3f9fefc (patch)
tree8ec91e0cf886a23068d75b87076dcfc7c837c10b
parent811b671e52d07b8737ae8008bb2bf18ebdca6d15 (diff)
downloadmetacity-a9ab7a62e23f8ec6bb1b1ee2da754dddd3f9fefc.tar.gz
testboxes: fix test_find_closest_point_to_line test
Use g_assert_cmpfloat_with_epsilon to compare floating points.
-rw-r--r--src/core/testboxes.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/testboxes.c b/src/core/testboxes.c
index e59db39b..d72e7a75 100644
--- a/src/core/testboxes.c
+++ b/src/core/testboxes.c
@@ -1361,7 +1361,9 @@ test_find_closest_point_to_line (void)
x2, y2,
px, py,
&rx, &ry);
- g_assert (rx == answer_x && ry == answer_y);
+
+ g_assert_cmpfloat_with_epsilon (rx, answer_x, 0.0001);
+ g_assert_cmpfloat_with_epsilon (ry, answer_y, 0.0001);
/* Special test for x1 == x2, so that slop of line is infinite */
x1 = 3.0; y1 = 49.0;
@@ -1372,7 +1374,9 @@ test_find_closest_point_to_line (void)
x2, y2,
px, py,
&rx, &ry);
- g_assert (rx == answer_x && ry == answer_y);
+
+ g_assert_cmpfloat_with_epsilon (rx, answer_x, 0.0001);
+ g_assert_cmpfloat_with_epsilon (ry, answer_y, 0.0001);
/* Special test for y1 == y2, so perp line has slope of infinity */
x1 = 3.14; y1 = 7.0;
@@ -1383,7 +1387,9 @@ test_find_closest_point_to_line (void)
x2, y2,
px, py,
&rx, &ry);
- g_assert (rx == answer_x && ry == answer_y);
+
+ g_assert_cmpfloat_with_epsilon (rx, answer_x, 0.0001);
+ g_assert_cmpfloat_with_epsilon (ry, answer_y, 0.0001);
/* Test when we the point we want to be closest to is actually on the line */
x1 = 3.0; y1 = 49.0;
@@ -1394,7 +1400,9 @@ test_find_closest_point_to_line (void)
x2, y2,
px, py,
&rx, &ry);
- g_assert (rx == answer_x && ry == answer_y);
+
+ g_assert_cmpfloat_with_epsilon (rx, answer_x, 0.0001);
+ g_assert_cmpfloat_with_epsilon (ry, answer_y, 0.0001);
printf ("%s passed.\n", G_STRFUNC);
}