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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
22#include <nlohmann/json.hpp>
23
24
25BOOST_AUTO_TEST_SUITE( JobExportSchPlot )
26
27
28BOOST_AUTO_TEST_CASE( VariantRoundTrip )
29{
31 job.m_variant = wxS( "var2" );
32
33 nlohmann::json j;
34 job.ToJson( j );
35
36 BOOST_CHECK_EQUAL( j.value( "variant_name", "" ), "var2" );
37
39 loaded.FromJson( j );
40
41 BOOST_CHECK( loaded.m_variant == wxS( "var2" ) );
42}
43
44
45BOOST_AUTO_TEST_CASE( EmptyVariantRoundTrip )
46{
48
49 nlohmann::json j;
50 job.ToJson( j );
51
52 BOOST_CHECK_EQUAL( j.value( "variant_name", "" ), "" );
53
55 loaded.FromJson( j );
56
57 BOOST_CHECK( loaded.m_variant.IsEmpty() );
58 BOOST_CHECK( loaded.m_variantNames.empty() );
59}
60
61
62BOOST_AUTO_TEST_CASE( VariantFromJobsetJson )
63{
64 // Simulate loading a jobset that specifies variant_name but not m_variantNames.
65 // This is the exact scenario from issue #22891.
66 nlohmann::json j = {
67 { "variant_name", "var2" },
68 { "format", "pdf" },
69 { "plot_all", true },
70 { "black_and_white", false }
71 };
72
74 loaded.FromJson( j );
75
76 BOOST_CHECK( loaded.m_variant == wxS( "var2" ) );
77 BOOST_CHECK( loaded.m_variantNames.empty() );
78}
79
80
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")