117 wxFileName netFile = m_schematic->Project().GetProjectFullName();
118 netFile.SetName( netFile.GetName() + wxT(
"_xml_test" ) );
119 netFile.SetExt( wxT(
"xml" ) );
121 if( wxFileExists( netFile.GetFullPath() ) )
122 wxRemoveFile( netFile.GetFullPath() );
125 std::unique_ptr<NETLIST_EXPORTER_XML> exporter =
126 std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
128 bool success = exporter->WriteNetlist( netFile.GetFullPath(), 0,
reporter );
135 wxXmlNode* root = xdoc.GetRoot();
138 wxXmlNode* nets =
find_child( root, wxT(
"nets" ) );
142 std::set<wxString> setA;
143 std::set<wxString> setB;
148 wxString netName = net->GetAttribute( wxT(
"name" ), wxEmptyString );
149 if( netName != wxT(
"VCC" ) && netName != wxT(
"GND" ) )
152 std::set<wxString>* target = ( foundSets == 0 ? &setA : &setB );
156 if( node->GetAttribute( wxT(
"ref" ), wxEmptyString ) != wxT(
"R1" ) )
159 wxString
pin = node->GetAttribute( wxT(
"pin" ), wxEmptyString );
160 wxString pinfunction = node->GetAttribute( wxT(
"pinfunction" ), wxEmptyString );
161 wxString pintype = node->GetAttribute( wxT(
"pintype" ), wxEmptyString );
168 target->insert(
pin );
175 BOOST_REQUIRE_EQUAL( foundSets, 2 );
178 const std::set<wxString> expectedTop =
as_set( {
"1",
"2",
"3",
"4",
"5" } );
179 const std::set<wxString> expectedBot =
as_set( {
"6",
"7",
"9",
"10",
"11" } );
181 bool matchA = ( setA == expectedTop && setB == expectedBot );
182 bool matchB = ( setA == expectedBot && setB == expectedTop );
183 BOOST_CHECK( matchA || matchB );
186 wxRemoveFile( netFile.GetFullPath() );
194 KI_TEST::LoadSchematic( m_settingsManager, wxT(
"netlist_exporter_unit_metadata_per_unit" ), m_schematic );
196 wxFileName netFile = m_schematic->Project().GetProjectFullName();
197 netFile.SetName( netFile.GetName() + wxT(
"_xml_unit_metadata_test" ) );
198 netFile.SetExt( wxT(
"xml" ) );
200 if( wxFileExists( netFile.GetFullPath() ) )
201 wxRemoveFile( netFile.GetFullPath() );
204 std::unique_ptr<NETLIST_EXPORTER_XML> exporter = std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
206 bool success = exporter->WriteNetlist( netFile.GetFullPath(), 0,
reporter );
212 wxXmlNode* root = xdoc.GetRoot();
215 wxXmlNode* components =
find_child( root, wxT(
"components" ) );
221 wxXmlNode* units =
find_child( u1, wxT(
"units" ) );
224 wxXmlNode* unitA =
find_unit( units, wxT(
"A" ) );
225 wxXmlNode* unitB =
find_unit( units, wxT(
"B" ) );
226 wxXmlNode* unitC =
find_unit( units, wxT(
"C" ) );
232 const std::vector<wxString> expectedUnitA{ wxT(
"3" ), wxT(
"2" ), wxT(
"1" ) };
233 const std::vector<wxString> expectedUnitB{ wxT(
"6" ), wxT(
"5" ), wxT(
"7" ) };
234 const std::vector<wxString> expectedUnitC{ wxT(
"8" ), wxT(
"4" ) };
240 wxRemoveFile( netFile.GetFullPath() );
BOOST_CHECK_EQUAL(result, "25.4")