32#include <boost/test/unit_test.hpp>
46#include <wx/filename.h>
54wxFileName MakeTempDir(
const wxString& aPrefix )
56 wxFileName tempDir( wxFileName::CreateTempFileName( wxString::Format( wxT(
"kicad-%s-" ), aPrefix ) ) );
60 BOOST_REQUIRE( tempDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
68struct ODB_EXPORT_STATE_GUARD
71 m_scale( PCB_IO_ODBPP::m_scale ),
72 m_symbolScale( PCB_IO_ODBPP::m_symbolScale ),
73 m_sigfig( PCB_IO_ODBPP::m_sigfig ),
74 m_unitsStr( PCB_IO_ODBPP::m_unitsStr )
89 std::string m_unitsStr;
93wxString ReadFile(
const wxFileName& aPath )
95 wxFFile stream( aPath.GetFullPath(), wxT(
"rb" ) );
107 wxFileName tempDir = MakeTempDir( wxT(
"odb-netlist" ) );
109 ODB_EXPORT_STATE_GUARD odbExportStateGuard;
130 pad->SetNumber( wxT(
"1" ) );
150 wxFileName odbRoot( tempDir.GetFullPath(), wxEmptyString );
151 odbRoot.AppendDir( wxT(
"odb_out" ) );
152 BOOST_REQUIRE( odbRoot.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
155 std::map<std::string, UTF8> props;
156 props[
"units"] =
"mm";
157 props[
"sigfig"] =
"6";
158 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( odbRoot.GetFullPath(), board, &props ) );
161 wxFileName netlistFile( odbRoot.GetFullPath(), wxEmptyString );
162 netlistFile.AppendDir( wxT(
"steps" ) );
163 netlistFile.AppendDir( wxT(
"pcb" ) );
164 netlistFile.AppendDir( wxT(
"netlists" ) );
165 netlistFile.AppendDir( wxT(
"cadnet" ) );
166 netlistFile.SetFullName( wxT(
"netlist" ) );
169 wxString netlistContent = ReadFile( netlistFile );
172 wxFileName compFile( odbRoot.GetFullPath(), wxEmptyString );
173 compFile.AppendDir( wxT(
"steps" ) );
174 compFile.AppendDir( wxT(
"pcb" ) );
175 compFile.AppendDir( wxT(
"layers" ) );
176 compFile.AppendDir( wxT(
"comp_+_top" ) );
177 compFile.SetFullName( wxT(
"components" ) );
180 wxString compContent = ReadFile( compFile );
188 BOOST_CHECK_MESSAGE( compContent.Contains( wxT(
"100" ) ),
189 "Component file should contain the pad X coordinate" );
195 BOOST_CHECK_MESSAGE( !netlistContent.Contains( wxT(
"50.0" ) ),
196 "Netlist should not contain aux-origin-shifted X coordinate 50.0" );
197 BOOST_CHECK_MESSAGE( netlistContent.Contains( wxT(
"100.0" ) ),
198 "Netlist should contain the raw pad X coordinate 100.0" );
201 wxFileName::Rmdir( odbRoot.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
202 wxFileName::Rmdir( tempDir.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
constexpr EDA_IU_SCALE pcbIUScale
void SetAuxOrigin(const VECTOR2I &aOrigin)
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetCopperLayerCount(int aCount)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
LSET is a set of PCB_LAYER_IDs.
Handle the data for a net.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static double m_symbolScale
Internal units to thousandths of the output unit, the scale ODB++ symbol names use.
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...
static std::string m_unitsStr
static double m_scale
Internal units to the output units named by m_unitsStr, for values written as data.
@ SMD
Smd pad, appears on the solder paste layer (default)
~ODB_EXPORT_STATE_GUARD()
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_CASE(ODBNetlistCoordinatesMatchFeatures)
VECTOR2< int32_t > VECTOR2I