58static std::vector<ODB_TOOL_RECORD>
parseOdbTools(
const fs::path& aToolsFile )
60 std::vector<ODB_TOOL_RECORD>
tools;
61 std::ifstream stream( aToolsFile );
64 auto value = [](
const std::string& aLine ) -> std::string
66 return aLine.substr( aLine.find(
'=' ) + 1 );
69 while( std::getline( stream, line ) )
71 const size_t start = line.find_first_not_of(
" \t" );
73 if( start == std::string::npos )
76 line = line.substr( start );
78 if( line.rfind(
"TOOLS", 0 ) == 0 )
80 else if(
tools.empty() )
82 else if( line.rfind(
"NUM=", 0 ) == 0 )
83 tools.back().m_num = std::stoi( value( line ) );
84 else if( line.rfind(
"FINISH_SIZE=", 0 ) == 0 )
85 tools.back().m_finishSize = std::stod( value( line ) );
86 else if( line.rfind(
"DRILL_SIZE=", 0 ) == 0 )
87 tools.back().m_drillSize = std::stod( value( line ) );
101 std::set<double> expectedSizes;
102 int npthHoleCount = 0;
104 for(
const PAD*
pad : board->GetPads() )
109 expectedSizes.insert(
pcbIUScale.IUTomm( std::min(
pad->GetDrillSize().x,
pad->GetDrillSize().y ) )
115 BOOST_REQUIRE_GT( npthHoleCount, (
int) expectedSizes.size() );
116 BOOST_REQUIRE_GT( expectedSizes.size(), 1 );
120 BOOST_REQUIRE_NO_THROW(
ExportOdb( *board, tempDir.
Path(), aUnits ) );
124 for(
const fs::directory_entry& entry : fs::recursive_directory_iterator( tempDir.
Path() ) )
126 if( entry.is_regular_file() && entry.path().filename() ==
"tools"
127 && entry.path().parent_path().filename().string().find(
"non-plated" )
128 != std::string::npos )
130 toolsFile = entry.path();
135 BOOST_REQUIRE_MESSAGE( !toolsFile.empty(),
136 "ODB++ export produced no non-plated drill tools file" );
138 std::ifstream unitsStream( toolsFile );
139 std::string unitsLine;
140 BOOST_REQUIRE(
static_cast<bool>( std::getline( unitsStream, unitsLine ) ) );
141 BOOST_CHECK_EQUAL( unitsLine, std::string(
"UNITS=" ) + ( std::string( aUnits ) ==
"mm" ?
"MM" :
"INCH" ) );
145 std::set<int> seenNums;
146 std::set<double> seenSizes;
150 BOOST_CHECK_MESSAGE( seenNums.insert( tool.m_num ).second,
151 "Drill tool number " << tool.m_num <<
" is used twice" );
154 seenSizes.insert( tool.m_drillSize );
158 BOOST_REQUIRE_EQUAL( seenSizes.size(), expectedSizes.size() );
160 auto actual = seenSizes.begin();
161 auto expected = expectedSizes.begin();
163 while(
actual != seenSizes.end() )
fs::path ExportOdb(const BOARD &aBoard, const fs::path &aDir, const std::string &aUnits, const std::string &aSigfig, REPORTER *aReporter)
BOOST_CHECK_EQUAL(result, "25.4")