27#include <fmt/format.h>
53 std::vector<wxString> cases = {
54 "Reverb_BTDR-1V.kicad_mod",
55 "Samtec_HLE-133-02-xx-DV-PE-LC_2x33_P2.54mm_Horizontal.kicad_mod",
56 "group_and_image.kicad_pcb"
59 std::unique_ptr<BOARD_ITEM_CONTAINER> original, prettified, golden;
62 std::string tempLibPath = fmt::format(
"{}/prettifier.pretty",
63 std::filesystem::temp_directory_path() );
64 std::filesystem::remove_all( tempLibPath );
65 std::filesystem::create_directory( tempLibPath );
67 for(
const wxString& testCase : cases )
69 std::string testCaseName = testCase.ToStdString();
71 BOOST_TEST_CONTEXT( testCaseName )
78 BOOST_REQUIRE( inFp.is_open() );
80 std::stringstream inBuf;
81 inBuf << inFp.rdbuf();
82 std::string inData = inBuf.str();
90 BOOST_REQUIRE( original.get() );
96 std::string tempPath = fmt::format(
"{}/{}", tempLibPath, testCaseName );
98 tempFp.open( tempPath );
99 BOOST_REQUIRE( tempFp.is_open() );
107 BOOST_CHECK_NO_THROW(
109 BOOST_REQUIRE( prettified.get() );
114 const_cast<KIID&
>( prettified->m_Uuid ) = original->m_Uuid;
117 BOOST_REQUIRE_MESSAGE( *original == *prettified,
118 "Formatted version of original board item does not parse the same way!" );
121 std::string base = testCase.BeforeLast(
'.' ).ToStdString();
122 std::string ext = testCase.AfterLast(
'.' ).ToStdString();
124 std::string goldenPath = fmt::format(
"{}prettifier/{}_formatted.{}",
127 std::ifstream goldFp;
128 goldFp.open( goldenPath );
129 BOOST_REQUIRE( goldFp.is_open() );
131 std::stringstream goldenBuf;
132 goldenBuf << goldFp.rdbuf();
134 BOOST_REQUIRE_MESSAGE( goldenBuf.str().compare( inData ) == 0,
135 "Formatting result doesn't match golden!" );
137 std::filesystem::remove( tempPath );
141 std::filesystem::remove_all( tempLibPath );
General utilities for PCB file IO for QA programs.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
Pcbnew s-expression file format parser definition.
SETTINGS_MANAGER m_settingsManager
PRETTIFIER_TEST_FIXTURE()
BOOST_FIXTURE_TEST_CASE(BoardAndFootprintPrettifier, PRETTIFIER_TEST_FIXTURE)