From a12a36f2fff6964b68dd45cb72ac3b3dd9f55dbd Mon Sep 17 00:00:00 2001 From: Letu Ren Date: Fri, 8 Dec 2023 15:56:34 +0800 Subject: [PATCH] Fix get_distance_measure test failure using MSVC Log is listed as follows. ``` Running 1 test case... test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_3 ctype: e tr_side: -1 dm_side: 1 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_4 ctype: e tr_side: -1 dm_side: 1 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_5 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_6 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_7 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_8 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_9 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_10 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_11 ctype: e tr_side: -1 dm_side: 0 test/algorithms/overlay/get_distance_measure.cpp(60): error: in "test_main_caller( argc_ argv )": Case: issue_1183_12 ctype: e tr_side: -1 dm_side: 0 *** 10 failures are detected in the test module "Test Program" ``` The reason is that in MSVC the long double type is identical to the double type. We should treat 64-bit long double as double. Modification to float is made for consistency. --- test/algorithms/overlay/get_distance_measure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/algorithms/overlay/get_distance_measure.cpp b/test/algorithms/overlay/get_distance_measure.cpp index df0322b35e..f526fe07a6 100644 --- a/test/algorithms/overlay/get_distance_measure.cpp +++ b/test/algorithms/overlay/get_distance_measure.cpp @@ -76,8 +76,8 @@ void test_get_distance_measure() do_test("simplex_left", {1.0, 0.0}, {1.0, 1.0}, {0.9, 0.5}, 1); do_test("simplex_right", {1.0, 0.0}, {1.0, 1.0}, {1.1, 0.5}, -1); - bool const is_float = std::is_same::value; - bool const is_double = std::is_same::value; + bool const is_float = std::is_floating_point::value && sizeof(coor_t) == 4; + bool const is_double = std::is_floating_point::value && sizeof(coor_t) == 8; // The issue 1183 where get_distance_measure failed for these coordinates. std::string const case_id = "issue_1183_";