KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_gencad_export.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 <boost/test/unit_test.hpp>
21#include <qa_utils/file_utils.h>
22
23#include <filesystem>
24#include <memory>
25
26#include <cli/exit_codes.h>
28#include <pcbnew_jobs_handler.h>
30
31#include <wx/string.h>
32
33
34BOOST_AUTO_TEST_CASE( ExportGencadWithFilename )
35{
36 PCBNEW_JOBS_HANDLER handler( nullptr );
37
38 const std::filesystem::path boardPath =
39 std::filesystem::path( KI_TEST::GetPcbnewTestDataDir() ) / "api_kitchen_sink.kicad_pcb";
40
41 BOOST_REQUIRE( std::filesystem::exists( boardPath ) );
42
43 KI_TEST::SCOPED_TEMP_DIR outputRoot( wxS( "kicad_gencad_export_test" ) );
44 const std::filesystem::path outputPath = outputRoot.Path() / "test_output.cad";
45
46 auto gencadJob = std::make_unique<JOB_EXPORT_PCB_GENCAD>();
47 gencadJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
48 gencadJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
49
50 int result = handler.JobExportGencad( gencadJob.get() );
52
53 BOOST_CHECK( std::filesystem::exists( outputPath ) );
54 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
55}
General utilities for PCB file IO for QA programs.
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
Definition file_utils.h:61
static const int OK
Definition exit_codes.h:30
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(ExportGencadWithFilename)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")