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
22#include <filesystem>
23#include <memory>
24
25#include <cli/exit_codes.h>
27#include <pcbnew_jobs_handler.h>
29
30#include <wx/string.h>
31
32
33BOOST_AUTO_TEST_CASE( ExportGencadWithFilename )
34{
35 PCBNEW_JOBS_HANDLER handler( nullptr );
36
37 const std::filesystem::path boardPath =
38 std::filesystem::path( KI_TEST::GetPcbnewTestDataDir() ) / "api_kitchen_sink.kicad_pcb";
39
40 BOOST_REQUIRE( std::filesystem::exists( boardPath ) );
41
42 const std::filesystem::path outputRoot =
43 std::filesystem::temp_directory_path() / "kicad_gencad_export_test";
44 const std::filesystem::path outputPath = outputRoot / "test_output.cad";
45
46 if( std::filesystem::exists( outputRoot ) )
47 std::filesystem::remove_all( outputRoot );
48
49 auto gencadJob = std::make_unique<JOB_EXPORT_PCB_GENCAD>();
50 gencadJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
51 gencadJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
52
53 int result = handler.JobExportGencad( gencadJob.get() );
55
56 BOOST_CHECK( std::filesystem::exists( outputPath ) );
57 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
58
59 std::filesystem::remove_all( outputRoot );
60}
General utilities for PCB file IO for QA programs.
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")