KiCad PCB EDA Suite
test_altium_parser_sch.cpp File Reference

Test suite for #ALTIUM_PARSER_SCH. More...

Go to the source code of this file.

Classes

struct  ALTIUM_PARSER_SCH_FIXTURE
 
struct  ALTIUM_TO_KICAD_UNIT_FRAC_CASE
 Declares the struct as the Boost test fixture. More...
 

Functions

int PropertiesReadKiCadUnitFrac (const std::map< wxString, wxString > &aProperties, const wxString &aKey)
 
 BOOST_AUTO_TEST_CASE (PropertiesReadKiCadUnitFracConversation)
 Test conversation from Altium internal units into KiCad internal units using properties with FRAC. More...
 

Variables

static const std::vector< ALTIUM_TO_KICAD_UNIT_FRAC_CASEaltium_to_kicad_unit_frac
 A list of valid internal unit conversation factors. More...
 

Detailed Description

Test suite for #ALTIUM_PARSER_SCH.

Definition in file test_altium_parser_sch.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( PropertiesReadKiCadUnitFracConversation  )

Test conversation from Altium internal units into KiCad internal units using properties with FRAC.

Definition at line 88 of file test_altium_parser_sch.cpp.

89 {
90  for( const auto& c : altium_to_kicad_unit_frac )
91  {
93  wxString::Format( wxT( "%s FRAC %s -> %i" ), c.input, c.input_frac, c.exp_result ) )
94  {
95  std::map<wxString, wxString> properties = { { "TEST", c.input },
96  { "TEST_FRAC", c.input_frac } };
97 
98  int result = PropertiesReadKiCadUnitFrac( properties, "TEST" );
99 
100  // These are all valid
101  BOOST_CHECK_EQUAL( result, c.exp_result );
102  }
103  }
104 }
int PropertiesReadKiCadUnitFrac(const std::map< wxString, wxString > &aProperties, const wxString &aKey)
static const std::vector< ALTIUM_TO_KICAD_UNIT_FRAC_CASE > altium_to_kicad_unit_frac
A list of valid internal unit conversation factors.
#define BOOST_TEST_CONTEXT(A)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References altium_to_kicad_unit_frac, BOOST_TEST_CONTEXT, Format(), and PropertiesReadKiCadUnitFrac().

◆ PropertiesReadKiCadUnitFrac()

int PropertiesReadKiCadUnitFrac ( const std::map< wxString, wxString > &  aProperties,
const wxString &  aKey 
)

Definition at line 50 of file altium_parser_sch.cpp.

52 {
53  // a unit is stored using two fields, denoting the size in mils and a fraction size
54  int key = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, 0 );
55  int keyFrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey + "_FRAC", 0 );
56  return Altium2KiCadUnit( key, keyFrac );
57 }
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)
constexpr int Altium2KiCadUnit(const int val, const int frac)

References Altium2KiCadUnit(), and ALTIUM_PARSER::PropertiesReadInt().

Referenced by ASCH_ARC::ASCH_ARC(), ASCH_BEZIER::ASCH_BEZIER(), ASCH_BUS::ASCH_BUS(), ASCH_BUS_ENTRY::ASCH_BUS_ENTRY(), ASCH_DESIGNATOR::ASCH_DESIGNATOR(), ASCH_FILE_NAME::ASCH_FILE_NAME(), ASCH_IMAGE::ASCH_IMAGE(), ASCH_JUNCTION::ASCH_JUNCTION(), ASCH_LABEL::ASCH_LABEL(), ASCH_LINE::ASCH_LINE(), ASCH_NET_LABEL::ASCH_NET_LABEL(), ASCH_NO_ERC::ASCH_NO_ERC(), ASCH_PARAMETER::ASCH_PARAMETER(), ASCH_POLYGON::ASCH_POLYGON(), ASCH_POLYLINE::ASCH_POLYLINE(), ASCH_PORT::ASCH_PORT(), ASCH_POWER_PORT::ASCH_POWER_PORT(), ASCH_RECTANGLE::ASCH_RECTANGLE(), ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE(), ASCH_SHEET_FONT::ASCH_SHEET_FONT(), ASCH_SHEET_NAME::ASCH_SHEET_NAME(), ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL(), ASCH_SYMBOL::ASCH_SYMBOL(), ASCH_WIRE::ASCH_WIRE(), and BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ altium_to_kicad_unit_frac

const std::vector<ALTIUM_TO_KICAD_UNIT_FRAC_CASE> altium_to_kicad_unit_frac
static
Initial value:
= {
{ "0", "0", 0 },
{ "1", "0", 2540 },
{ "2", "0", 5080 },
{ "-1", "0", -2540 },
{ "-2", "0", -5080 },
{ "0", "1", 0 },
{ "0", "10", 0 },
{ "0", "100", 2 },
{ "0", "1000", 25 },
{ "0", "10000", 254 },
{ "1", "10000", 2794 },
{ "0", "-1", 0 },
{ "0", "-10", 0 },
{ "0", "-100", -2 },
{ "0", "-1000", -25 },
{ "0", "-10000", -254 },
{ "-1", "-10000", -2794 },
}

A list of valid internal unit conversation factors.

Definition at line 59 of file test_altium_parser_sch.cpp.

Referenced by BOOST_AUTO_TEST_CASE().