KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_job_export_sch_plot.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>
26#include <nlohmann/json.hpp>
27
28
29BOOST_AUTO_TEST_SUITE( JobExportSchPlot )
30
31
32BOOST_AUTO_TEST_CASE( VariantRoundTrip )
33{
35 job.m_variant = wxS( "var2" );
36
37 nlohmann::json j;
38 job.ToJson( j );
39
40 BOOST_CHECK_EQUAL( j.value( "variant_name", "" ), "var2" );
41
43 loaded.FromJson( j );
44
45 BOOST_CHECK( loaded.m_variant == wxS( "var2" ) );
46}
47
48
49BOOST_AUTO_TEST_CASE( EmptyVariantRoundTrip )
50{
52
53 nlohmann::json j;
54 job.ToJson( j );
55
56 BOOST_CHECK_EQUAL( j.value( "variant_name", "" ), "" );
57
59 loaded.FromJson( j );
60
61 BOOST_CHECK( loaded.m_variant.IsEmpty() );
62 BOOST_CHECK( loaded.m_variantNames.empty() );
63}
64
65
66BOOST_AUTO_TEST_CASE( VariantFromJobsetJson )
67{
68 // Simulate loading a jobset that specifies variant_name but not m_variantNames.
69 // This is the exact scenario from issue #22891.
70 nlohmann::json j = {
71 { "variant_name", "var2" },
72 { "format", "pdf" },
73 { "plot_all", true },
74 { "black_and_white", false }
75 };
76
78 loaded.FromJson( j );
79
80 BOOST_CHECK( loaded.m_variant == wxS( "var2" ) );
81 BOOST_CHECK( loaded.m_variantNames.empty() );
82}
83
84
std::vector< wxString > m_variantNames
virtual void FromJson(const nlohmann::json &j)
Definition job.cpp:60
virtual void ToJson(nlohmann::json &j) const
Definition job.cpp:67
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(VariantRoundTrip)
BOOST_CHECK_EQUAL(result, "25.4")