32#include <boost/test/unit_test.hpp>
46#include <wx/filename.h>
54wxFileName MakeTempDir(
const wxString& aPrefix )
57 wxFileName::CreateTempFileName( wxString::Format( wxT(
"kicad-%s-" ), aPrefix ) ) );
61 BOOST_REQUIRE( tempDir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
69struct ODB_EXPORT_STATE_GUARD
71 ODB_EXPORT_STATE_GUARD() :
72 m_scale( PCB_IO_ODBPP::m_scale ),
73 m_symbolScale( PCB_IO_ODBPP::m_symbolScale ),
74 m_sigfig( PCB_IO_ODBPP::m_sigfig ),
75 m_unitsStr( PCB_IO_ODBPP::m_unitsStr )
79 ~ODB_EXPORT_STATE_GUARD()
90 std::string m_unitsStr;
94wxString ReadFile(
const wxFileName& aPath )
96 wxFFile stream( aPath.GetFullPath(), wxT(
"rb" ) );
108 wxFileName tempDir = MakeTempDir( wxT(
"odb-netlist" ) );
110 ODB_EXPORT_STATE_GUARD odbExportStateGuard;
130 pad->SetNumber( wxT(
"1" ) );
149 wxFileName odbRoot( tempDir.GetFullPath(), wxEmptyString );
150 odbRoot.AppendDir( wxT(
"odb_out" ) );
151 BOOST_REQUIRE( odbRoot.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) );
154 std::map<std::string, UTF8> props;
155 props[
"units"] =
"mm";
156 props[
"sigfig"] =
"6";
157 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( odbRoot.GetFullPath(), &board, &props ) );
160 wxFileName netlistFile( odbRoot.GetFullPath(), wxEmptyString );
161 netlistFile.AppendDir( wxT(
"steps" ) );
162 netlistFile.AppendDir( wxT(
"pcb" ) );
163 netlistFile.AppendDir( wxT(
"netlists" ) );
164 netlistFile.AppendDir( wxT(
"cadnet" ) );
165 netlistFile.SetFullName( wxT(
"netlist" ) );
168 wxString netlistContent = ReadFile( netlistFile );
171 wxFileName compFile( odbRoot.GetFullPath(), wxEmptyString );
172 compFile.AppendDir( wxT(
"steps" ) );
173 compFile.AppendDir( wxT(
"pcb" ) );
174 compFile.AppendDir( wxT(
"layers" ) );
175 compFile.AppendDir( wxT(
"comp_+_top" ) );
176 compFile.SetFullName( wxT(
"components" ) );
179 wxString compContent = ReadFile( compFile );
188 "Component file should contain the pad X coordinate" );
195 "Netlist should not contain aux-origin-shifted X coordinate 50.0" );
197 "Netlist should contain the raw pad X coordinate 100.0" );
200 wxFileName::Rmdir( odbRoot.GetFullPath(), wxPATH_RMDIR_RECURSIVE );
201 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.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
static double m_symbolScale
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
@ SMD
Smd pad, appears on the solder paste layer (default)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_CASE(ODBNetlistCoordinatesMatchFeatures)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
VECTOR2< int32_t > VECTOR2I