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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <boost/test/unit_test.hpp>
25
26#include <filesystem>
27#include <memory>
28
29#include <cli/exit_codes.h>
31#include <pcbnew_jobs_handler.h>
33
34#include <wx/string.h>
35
36
37BOOST_AUTO_TEST_CASE( ExportGencadWithFilename )
38{
39 PCBNEW_JOBS_HANDLER handler( nullptr );
40
41 const std::filesystem::path boardPath =
42 std::filesystem::path( KI_TEST::GetPcbnewTestDataDir() ) / "api_kitchen_sink.kicad_pcb";
43
44 BOOST_REQUIRE( std::filesystem::exists( boardPath ) );
45
46 const std::filesystem::path outputRoot =
47 std::filesystem::temp_directory_path() / "kicad_gencad_export_test";
48 const std::filesystem::path outputPath = outputRoot / "test_output.cad";
49
50 if( std::filesystem::exists( outputRoot ) )
51 std::filesystem::remove_all( outputRoot );
52
53 auto gencadJob = std::make_unique<JOB_EXPORT_PCB_GENCAD>();
54 gencadJob->m_filename = wxString::FromUTF8( boardPath.string().c_str() );
55 gencadJob->SetConfiguredOutputPath( wxString::FromUTF8( outputPath.string().c_str() ) );
56
57 int result = handler.JobExportGencad( gencadJob.get() );
59
60 BOOST_CHECK( std::filesystem::exists( outputPath ) );
61 BOOST_CHECK( std::filesystem::is_regular_file( outputPath ) );
62
63 std::filesystem::remove_all( outputRoot );
64}
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")