From 438c4b58a3e9e050dc7f369c13a153a15b91eaa5 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 27 Dec 2022 19:56:04 +0100 Subject: [PATCH] Try to fix a QA issue probably due to the order some Ctors are called. This is not the first time an issue is created by the order of ctors. --- .../geometry/test_ellipse_to_bezier.cpp | 97 +++++++++---------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/qa/unittests/libs/kimath/geometry/test_ellipse_to_bezier.cpp b/qa/unittests/libs/kimath/geometry/test_ellipse_to_bezier.cpp index 1e7ddb9842..2abc9fc9f2 100644 --- a/qa/unittests/libs/kimath/geometry/test_ellipse_to_bezier.cpp +++ b/qa/unittests/libs/kimath/geometry/test_ellipse_to_bezier.cpp @@ -38,57 +38,56 @@ struct ELLIPSE_TO_BEZIER_CASE }; -// clang-format off -static const std::vector cases = { - { - "full circle", - { { 0, 0 }, { 100, 0 }, 1.0, ANGLE_0, FULL_CIRCLE }, - { { { 100, 0 }, { 100, -55.22847498307934 }, { 55.228474983079344, -100 }, { 0, -100 } }, - { { 0, -100 }, { -55.22847498307934, -100 }, { -100, -55.228474983079344 }, { -100, 0 } }, - { { -100, 0 }, { -100, 55.22847498307934 }, { -55.228474983079344, 100 }, { 0, 100 } }, - { { 0, 100 }, { 55.22847498307934, 100 }, { 100, 55.228474983079344 }, { 100, 0 } } - } - }, - { - "ellipse", - { { 0, 0 }, { -100, 0 }, 0.5, ANGLE_0, FULL_CIRCLE }, - { { { -100, 0 }, { -100, 27.61423749153967 }, { -55.228474983079344, 50 }, { 0, 50 } }, - { { 0, 50 }, { 55.22847498307934, 50 }, { 100, 27.614237491539672 }, { 100, 0 } }, - { { 100, 0 }, { 100, -27.61423749153967 }, { 55.228474983079344, -50 }, { 0, -50 } }, - { { 0, -50 }, { -55.22847498307934, -50 }, { -100, -27.614237491539672 }, { -100, 0 } } - } - }, - { - "arc1", - { { 0, 0 }, { 100, 0 }, 0.5, ANGLE_180, FULL_CIRCLE }, - { { { 100, 0 }, { 100, -27.61423749153967 }, { 55.228474983079344, -50 }, { 0, -50 } }, - { { 0, -50 }, { -55.22847498307934, -50 }, { -100, -27.614237491539672 }, { -100, 0 } }, - { { -100, 0 }, { -100, 27.61423749153967 }, { -55.228474983079344, 50 }, { 0, 50 } }, - { { 0, 50 }, { 55.22847498307934, 50 }, { 100, 27.614237491539672 }, { 100, 0 } } - } - }, - { - "arc2", - { { 223, 165 }, { 372, 634 }, 0.96, EDA_ANGLE( 4.437, RADIANS_T ), EDA_ANGLE( 0.401, RADIANS_T ) }, - { { { -463.86, 336.27 }, { -389.81, 608.33 }, { -170.75, 818.49 }, { 99.52, 876.73 } }, - { { 99.52, 876.73 }, { 369.80, 934.98 }, { 643.36, 831.0 }, { 803.07, 609.31 } } - } - }, - { - "arc3", - { { 112.75, 490.24 }, { 304.54, 129.16 }, 7.14, EDA_ANGLE( 1.90, RADIANS_T ), EDA_ANGLE( 1.09, RADIANS_T ) }, - { { { 886.98, -1609.17 }, { 608.61, -1333.45 }, { 110.16, -394.92 }, { -305.88, 636.89 } }, - { { -305.88, 636.89 }, { -721.93, 1668.69 }, { -940.88, 2509.32 }, { -829.87, 2648.63 } }, - { { -829.87, 2648.63 }, { -718.85, 2787.95 }, { -308.47, 2187.55 }, { 152.23, 1211.78 } }, - { { 152.23, 1211.78 }, { 612.93, 236.01 }, { 996.95, -846.11 }, { 1071.24, -1377.92 } } - } - }, -}; -// clang-format on - - BOOST_AUTO_TEST_CASE( EllipseToBezier ) { + // This data mut be created "on the fly" to avoid a CTOR odres issue, because it uses + // static data like ANGLE_0 and it must be created **after** ANGLE_0 CTOR is called + // clang-format off + static const std::vector cases = { + { + "full circle", + { { 0, 0 }, { 100, 0 }, 1.0, ANGLE_0, FULL_CIRCLE }, + { { { 100, 0 }, { 100, -55.22847498307934 }, { 55.228474983079344, -100 }, { 0, -100 } }, + { { 0, -100 }, { -55.22847498307934, -100 }, { -100, -55.228474983079344 }, { -100, 0 } }, + { { -100, 0 }, { -100, 55.22847498307934 }, { -55.228474983079344, 100 }, { 0, 100 } }, + { { 0, 100 }, { 55.22847498307934, 100 }, { 100, 55.228474983079344 }, { 100, 0 } } + } + }, + { + "ellipse", + { { 0, 0 }, { -100, 0 }, 0.5, ANGLE_0, FULL_CIRCLE }, + { { { -100, 0 }, { -100, 27.61423749153967 }, { -55.228474983079344, 50 }, { 0, 50 } }, + { { 0, 50 }, { 55.22847498307934, 50 }, { 100, 27.614237491539672 }, { 100, 0 } }, + { { 100, 0 }, { 100, -27.61423749153967 }, { 55.228474983079344, -50 }, { 0, -50 } }, + { { 0, -50 }, { -55.22847498307934, -50 }, { -100, -27.614237491539672 }, { -100, 0 } } + } + }, + { + "arc1", + { { 0, 0 }, { 100, 0 }, 0.5, ANGLE_180, FULL_CIRCLE }, + { { { -100, 0 }, { -100, 27.61423749153967 }, { -55.228474983079344, 50 }, { 0, 50 } }, + { { 0, 50 }, { 55.22847498307934, 50 }, { 100, 27.614237491539672 }, { 100, 0 } } + } + }, + { + "arc2", + { { 223, 165 }, { 372, 634 }, 0.96, EDA_ANGLE( 4.437, RADIANS_T ), EDA_ANGLE( 0.401, RADIANS_T ) }, + { { { -463.86, 336.27 }, { -389.81, 608.33 }, { -170.75, 818.49 }, { 99.52, 876.73 } }, + { { 99.52, 876.73 }, { 369.80, 934.98 }, { 643.36, 831.0 }, { 803.07, 609.31 } } + } + }, + { + "arc3", + { { 112.75, 490.24 }, { 304.54, 129.16 }, 7.14, EDA_ANGLE( 1.90, RADIANS_T ), EDA_ANGLE( 1.09, RADIANS_T ) }, + { { { 886.98, -1609.17 }, { 608.61, -1333.45 }, { 110.16, -394.92 }, { -305.88, 636.89 } }, + { { -305.88, 636.89 }, { -721.93, 1668.69 }, { -940.88, 2509.32 }, { -829.87, 2648.63 } }, + { { -829.87, 2648.63 }, { -718.85, 2787.95 }, { -308.47, 2187.55 }, { 152.23, 1211.78 } }, + { { 152.23, 1211.78 }, { 612.93, 236.01 }, { 996.95, -846.11 }, { 1071.24, -1377.92 } } + } + }, + }; + // clang-format on + for( const ELLIPSE_TO_BEZIER_CASE& c : cases ) { BOOST_TEST_CONTEXT( c.name )