Altium: migrate test_altium_parser_utils.cpp to use BOOST_DATA_TEST_CASE

This commit is contained in:
Thomas Pointhuber 2024-05-12 17:10:45 +02:00
parent 01892ab98f
commit 0890594f75
1 changed files with 17 additions and 20 deletions

View File

@ -49,6 +49,10 @@ struct SPECIAL_STRINGS_TO_KICAD
std::map<wxString, wxString> 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<SPECIAL_STRINGS_TO_KICAD> 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 );
wxString result = AltiumSchSpecialStringsToKiCadVariables( data.input, data.override );
// These are all valid
BOOST_CHECK_EQUAL( result, c.exp_result );
}
}
// 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<SPECIAL_STRINGS_TO_KICAD> 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 );
wxString result = AltiumPcbSpecialStringsToKiCadStrings( data.input, data.override );
// These are all valid
BOOST_CHECK_EQUAL( result, c.exp_result );
}
}
// These are all valid
BOOST_CHECK_EQUAL( result, data.exp_result );
}
BOOST_AUTO_TEST_SUITE_END()