KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_save_load.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <filesystem>
21
23#include <boost/test/data/test_case.hpp>
24
27#include <board.h>
29
30
31namespace
32{
33struct SAVE_LOAD_TEST_FIXTURE
34{
35 SAVE_LOAD_TEST_FIXTURE()
36 { }
37
38 SETTINGS_MANAGER m_settingsManager;
39 std::unique_ptr<BOARD> m_board;
40};
41
42const std::vector<wxString> RegressionSaveLoadTests_tests = {
43 "issue18",
44 "issue832",
45 "issue2568",
46 "issue5313",
47 "issue5854",
48 "issue6260",
49 "issue6945",
50 "issue7267",
51 "padstacks",
52 "padstacks_normal",
53 "padstacks_complex"
54 /* "issue8003", */ // issue8003 is flaky on some platforms
55};
56
57}; // namespace
58
59
60BOOST_DATA_TEST_CASE_F( SAVE_LOAD_TEST_FIXTURE, RegressionSaveLoadTests,
61 boost::unit_test::data::make( RegressionSaveLoadTests_tests ), relPath )
62{
63 const std::filesystem::path savePath = std::filesystem::temp_directory_path() / "group_saveload_tst.kicad_pcb";
64
65 KI_TEST::LoadBoard( m_settingsManager, relPath, m_board );
66 KI_TEST::DumpBoardToFile( *m_board.get(), savePath.string() );
67
68 std::unique_ptr<BOARD> board2 = KI_TEST::ReadBoardFromFileOrStream( savePath.string() );
69}
General utilities for PCB file IO for QA programs.
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::string &aFilename)
Utility function to simply write a Board out to a file.
BOOST_DATA_TEST_CASE_F(SAVE_LOAD_TEST_FIXTURE, RegressionSaveLoadTests, boost::unit_test::data::make(RegressionSaveLoadTests_tests), relPath)