70 pad->SetNumber( wxT(
"1" ) );
96 wxString tempPath = wxFileName::CreateTempFileName( wxT(
"kicad_ipc2581_test" ) );
98 std::map<std::string, UTF8> props;
99 props[
"units"] =
"mm";
100 props[
"version"] =
"C";
101 props[
"sigfig"] =
"3";
103 BOOST_REQUIRE_NO_THROW( ipc2581Plugin.
SaveBoard( tempPath, board, &props ) );
106 std::ifstream xmlFile( tempPath.ToStdString() );
109 std::string xml( ( std::istreambuf_iterator<char>( xmlFile ) ),
110 std::istreambuf_iterator<char>() );
115 auto componentRegion =
116 [&](
const std::string& aRef ) -> std::string
118 size_t start = xml.find(
"refDes=\"" + aRef +
"\"" );
120 if( start == std::string::npos )
121 return std::string();
123 size_t end = xml.find(
"</Component>", start );
125 return xml.substr( start,
end == std::string::npos ? std::string::npos
129 std::string u1 = componentRegion(
"U1" );
130 BOOST_REQUIRE_MESSAGE( !u1.empty(),
"Flipped component U1 should be exported" );
132 BOOST_CHECK_MESSAGE( u1.find(
"mirror=\"true\"" ) != std::string::npos,
133 "Flipped component must carry mirror=\"true\". Region: " + u1 );
134 BOOST_CHECK_MESSAGE( u1.find(
"rotation=\"150.0\"" ) != std::string::npos,
135 "Flipped 30 degree component must export rotation=\"150.0\". Region: " + u1 );
138 BOOST_CHECK_MESSAGE( u1.find(
"rotation=\"330.0\"" ) == std::string::npos,
139 "Flipped rotation must not be a bare Invert() (330.0). Region: " + u1 );
140 BOOST_CHECK_MESSAGE( u1.find(
"rotation=\"30.0\"" ) == std::string::npos,
141 "Flipped rotation must not be the unadjusted orientation (30.0). Region: " + u1 );
143 std::string u2 = componentRegion(
"U2" );
144 BOOST_REQUIRE_MESSAGE( !u2.empty(),
"Top component U2 should be exported" );
146 BOOST_CHECK_MESSAGE( u2.find(
"mirror=\"true\"" ) == std::string::npos,
147 "Top component must not be mirrored. Region: " + u2 );
148 BOOST_CHECK_MESSAGE( u2.find(
"rotation=\"30.0\"" ) != std::string::npos,
149 "Top 30 degree component must export rotation=\"30.0\". Region: " + u2 );
151 std::filesystem::remove( std::filesystem::path( tempPath.ToStdString() ) );
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SaveBoard(const wxString &aFileName, BOARD &aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...