20#include <boost/test/tools/context.hpp>
23#include <boost/test/unit_test.hpp>
39#ifndef QA_PCBNEW_DATA_LOCATION
40 #define QA_PCBNEW_DATA_LOCATION "???"
45 const char* env = std::getenv(
"KICAD_TEST_PCBNEW_DATA_DIR" );
69 io.
SaveBoard( aFilename.string(), board );
80 std::unique_ptr<BOARD_ITEM> board;
84 board.reset( parser.
Parse() );
96 std::istream& aFallback )
98 std::istream* in_stream =
nullptr;
99 std::ifstream file_stream;
101 if( aFilename.empty() )
104 in_stream = &aFallback;
108 file_stream.open( aFilename );
110 if( !file_stream.is_open() )
115 in_stream = &file_stream;
130 std::unique_ptr<BOARD> board;
145 std::istream& aFallback )
147 std::istream* in_stream =
nullptr;
148 std::ifstream file_stream;
150 if( aFilename.empty() )
153 in_stream = &aFallback;
157 file_stream.open( aFilename );
159 if( !file_stream.is_open() )
164 in_stream = &file_stream;
180 io.
FootprintSave( aLibraryPath.string(), &aFootprint,
nullptr );
#define QA_PCBNEW_DATA_LOCATION
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
A PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
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...
LINE_READER that wraps a given std::istream instance.
void SetStream(std::istream &aStream)
Set the stream for this line reader.
Test utilities for timestamps.
std::unique_ptr< BOARD > ReadBoardFromFile(const std::filesystem::path &aFilename)
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
void DumpFootprintToFile(const FOOTPRINT &aFootprint, const std::filesystem::path &aLibraryPath)
Same as DumpBoardToFile, but for footprints.
std::unique_ptr< BOARD > RequireBoardFromPcbnewQAData(const std::filesystem::path &aFilename)
Require a board from the path relative to the pcbnew QA data directory.
std::unique_ptr< ITEM > ReadItemFromStream(std::istream &aStream)
Read a specific kind of BOARD_ITEM from a stream.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
std::unique_ptr< FOOTPRINT > ReadFootprintFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
std::unique_ptr< BOARD_ITEM > ReadBoardItemFromStream(std::istream &aStream)
Utility function to read a BOARD_ITEM (probably a FOOTPRINT or a BOARD) from a file.
std::unique_ptr< FOOTPRINT > ReadFootprintFromFile(const std::filesystem::path &aFilename)
Pcbnew s-expression file format parser definition.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_TEST_CONTEXT("Test Clearance")