From 0890594f75e55772b9d6ff92c79718c77278c0ae Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sun, 12 May 2024 17:10:45 +0200 Subject: [PATCH] Altium: migrate test_altium_parser_utils.cpp to use BOOST_DATA_TEST_CASE --- .../io/altium/test_altium_parser_utils.cpp | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/qa/tests/common/io/altium/test_altium_parser_utils.cpp b/qa/tests/common/io/altium/test_altium_parser_utils.cpp index 190ed72df6..b7f6e225d9 100644 --- a/qa/tests/common/io/altium/test_altium_parser_utils.cpp +++ b/qa/tests/common/io/altium/test_altium_parser_utils.cpp @@ -49,6 +49,10 @@ struct SPECIAL_STRINGS_TO_KICAD std::map override; }; +std::ostream & operator<<(std::ostream & strm, SPECIAL_STRINGS_TO_KICAD const & data) { + return strm << "[" << data.input << " -> " << data.exp_result << "]"; +} + /** * A list of valid test strings and the expected results */ @@ -134,20 +138,17 @@ static const std::vector sch_special_string_to_kicad_p /** * Test conversation from Altium Schematic Special String to a KiCad String with variables */ -BOOST_AUTO_TEST_CASE( AltiumSchSpecialStringsToKiCadVariablesProperties ) +BOOST_DATA_TEST_CASE( AltiumSchSpecialStringsToKiCadVariablesProperties, + boost::unit_test::data::make(sch_special_string_to_kicad_property), + data ) { - for( const auto& c : sch_special_string_to_kicad_property ) - { - BOOST_TEST_CONTEXT( wxString::Format( wxT( "'%s' -> '%s'" ), c.input, c.exp_result ) ) - { - wxString result = AltiumSchSpecialStringsToKiCadVariables( c.input, c.override ); - - // These are all valid - BOOST_CHECK_EQUAL( result, c.exp_result ); - } - } + wxString result = AltiumSchSpecialStringsToKiCadVariables( data.input, data.override ); + + // These are all valid + BOOST_CHECK_EQUAL( result, data.exp_result ); } + /** * A list of valid test strings and the expected results */ @@ -202,18 +203,14 @@ static const std::vector pcb_special_string_to_kicad_p /** * Test conversation from Altium Board Special String to a KiCad String with variables */ -BOOST_AUTO_TEST_CASE( AltiumPcbSpecialStringsToKiCadStringsProperties ) +BOOST_DATA_TEST_CASE( AltiumPcbSpecialStringsToKiCadStringsProperties, + boost::unit_test::data::make(pcb_special_string_to_kicad_property), + data ) { - for( const auto& c : pcb_special_string_to_kicad_property ) - { - BOOST_TEST_CONTEXT( wxString::Format( wxT( "'%s' -> '%s'" ), c.input, c.exp_result ) ) - { - wxString result = AltiumPcbSpecialStringsToKiCadStrings( c.input, c.override ); - - // These are all valid - BOOST_CHECK_EQUAL( result, c.exp_result ); - } - } + wxString result = AltiumPcbSpecialStringsToKiCadStrings( data.input, data.override ); + + // These are all valid + BOOST_CHECK_EQUAL( result, data.exp_result ); } BOOST_AUTO_TEST_SUITE_END()