KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue1441_bom_default_filename.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// Regression tests for https://gitlab.com/kicad/code/kicad/-/issues/1441
21//
22// A blank BOM output-file path used to be a hard error. The exporter now defaults to
23// <schematic>.csv beside the schematic, matching the other KiCad exporters. An unsaved
24// schematic (no file name) still yields no destination so callers keep the error.
25
27
29
30
31BOOST_AUTO_TEST_SUITE( Issue1441BomDefaultFileName )
32
33
34BOOST_AUTO_TEST_CASE( SwapsExtensionToCsv )
35{
36 wxFileName expected( wxS( "/tmp/project/design.csv" ) );
37
38 BOOST_CHECK_EQUAL( DIALOG_SYMBOL_FIELDS_TABLE::GetDefaultBomFileName( wxS( "/tmp/project/design.kicad_sch" ) ),
39 expected.GetFullPath() );
40}
41
42
43BOOST_AUTO_TEST_CASE( PreservesDirectory )
44{
45 // The default lands next to the schematic, not in the current working directory.
46 wxFileName result( DIALOG_SYMBOL_FIELDS_TABLE::GetDefaultBomFileName( wxS( "/tmp/project/design.kicad_sch" ) ) );
47
48 BOOST_CHECK_EQUAL( result.GetPath(), wxS( "/tmp/project" ) );
49 BOOST_CHECK_EQUAL( result.GetExt(), wxS( "csv" ) );
50}
51
52
53BOOST_AUTO_TEST_CASE( EmptyForUnsavedSchematic )
54{
55 BOOST_CHECK( DIALOG_SYMBOL_FIELDS_TABLE::GetDefaultBomFileName( wxEmptyString ).IsEmpty() );
56}
57
58
static wxString GetDefaultBomFileName(const wxString &aInputFileName)
Derive the default BOM output file name from the input file name by swapping the extension to CSV.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(SwapsExtensionToCsv)
VECTOR3I expected(15, 30, 45)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")