118 wxFileName netFile = m_schematic->Project().GetProjectFullName();
119 netFile.SetName( netFile.GetName() + wxT(
"_xml_test" ) );
120 netFile.SetExt( wxT(
"xml" ) );
122 if( wxFileExists( netFile.GetFullPath() ) )
123 wxRemoveFile( netFile.GetFullPath() );
126 std::unique_ptr<NETLIST_EXPORTER_XML> exporter =
127 std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
129 bool success = exporter->WriteNetlist( netFile.GetFullPath(), 0, reporter );
136 wxXmlNode* root = xdoc.GetRoot();
139 wxXmlNode* nets =
find_child( root, wxT(
"nets" ) );
143 std::set<wxString> setA;
144 std::set<wxString> setB;
149 wxString netName = net->GetAttribute( wxT(
"name" ), wxEmptyString );
150 if( netName != wxT(
"VCC" ) && netName != wxT(
"GND" ) )
153 std::set<wxString>* target = ( foundSets == 0 ? &setA : &setB );
157 if( node->GetAttribute( wxT(
"ref" ), wxEmptyString ) != wxT(
"R1" ) )
160 wxString
pin = node->GetAttribute( wxT(
"pin" ), wxEmptyString );
161 wxString pinfunction = node->GetAttribute( wxT(
"pinfunction" ), wxEmptyString );
162 wxString pintype = node->GetAttribute( wxT(
"pintype" ), wxEmptyString );
169 target->insert(
pin );
176 BOOST_REQUIRE_EQUAL( foundSets, 2 );
179 const std::set<wxString> expectedTop =
as_set( {
"1",
"2",
"3",
"4",
"5" } );
180 const std::set<wxString> expectedBot =
as_set( {
"6",
"7",
"9",
"10",
"11" } );
182 bool matchA = ( setA == expectedTop && setB == expectedBot );
183 bool matchB = ( setA == expectedBot && setB == expectedTop );
184 BOOST_CHECK( matchA || matchB );
187 wxRemoveFile( netFile.GetFullPath() );
195 KI_TEST::LoadSchematic( m_settingsManager, wxT(
"netlist_exporter_unit_metadata_per_unit" ), m_schematic );
197 wxFileName netFile = m_schematic->Project().GetProjectFullName();
198 netFile.SetName( netFile.GetName() + wxT(
"_xml_unit_metadata_test" ) );
199 netFile.SetExt( wxT(
"xml" ) );
201 if( wxFileExists( netFile.GetFullPath() ) )
202 wxRemoveFile( netFile.GetFullPath() );
205 std::unique_ptr<NETLIST_EXPORTER_XML> exporter = std::make_unique<NETLIST_EXPORTER_XML>( m_schematic.get() );
207 bool success = exporter->WriteNetlist( netFile.GetFullPath(), 0, reporter );
213 wxXmlNode* root = xdoc.GetRoot();
216 wxXmlNode* components =
find_child( root, wxT(
"components" ) );
222 wxXmlNode* units =
find_child( u1, wxT(
"units" ) );
225 wxXmlNode* unitA =
find_unit( units, wxT(
"A" ) );
226 wxXmlNode* unitB =
find_unit( units, wxT(
"B" ) );
227 wxXmlNode* unitC =
find_unit( units, wxT(
"C" ) );
233 const std::vector<wxString> expectedUnitA{ wxT(
"3" ), wxT(
"2" ), wxT(
"1" ) };
234 const std::vector<wxString> expectedUnitB{ wxT(
"6" ), wxT(
"5" ), wxT(
"7" ) };
235 const std::vector<wxString> expectedUnitC{ wxT(
"8" ), wxT(
"4" ) };
241 wxRemoveFile( netFile.GetFullPath() );
BOOST_CHECK_EQUAL(result, "25.4")