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>
25
#include <
jobs/job_export_sch_plot.h
>
26
#include <nlohmann/json.hpp>
27
28
29
BOOST_AUTO_TEST_SUITE
( JobExportSchPlot )
30
31
32
BOOST_AUTO_TEST_CASE
( VariantRoundTrip )
33
{
34
JOB_EXPORT_SCH_PLOT_PDF
job;
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
42
JOB_EXPORT_SCH_PLOT_PDF
loaded;
43
loaded.
FromJson
( j );
44
45
BOOST_CHECK( loaded.
m_variant
== wxS(
"var2"
) );
46
}
47
48
49
BOOST_AUTO_TEST_CASE
( EmptyVariantRoundTrip )
50
{
51
JOB_EXPORT_SCH_PLOT_PDF
job;
52
53
nlohmann::json j;
54
job.
ToJson
( j );
55
56
BOOST_CHECK_EQUAL
( j.value(
"variant_name"
,
""
),
""
);
57
58
JOB_EXPORT_SCH_PLOT_PDF
loaded;
59
loaded.
FromJson
( j );
60
61
BOOST_CHECK( loaded.
m_variant
.IsEmpty() );
62
BOOST_CHECK( loaded.
m_variantNames
.empty() );
63
}
64
65
66
BOOST_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
77
JOB_EXPORT_SCH_PLOT_PDF
loaded;
78
loaded.
FromJson
( j );
79
80
BOOST_CHECK( loaded.
m_variant
== wxS(
"var2"
) );
81
BOOST_CHECK( loaded.
m_variantNames
.empty() );
82
}
83
84
85
BOOST_AUTO_TEST_SUITE_END
()
JOB_EXPORT_SCH_PLOT_PDF
Definition
job_export_sch_plot.h:78
JOB_EXPORT_SCH_PLOT::m_variant
wxString m_variant
Definition
job_export_sch_plot.h:56
JOB_EXPORT_SCH_PLOT::m_variantNames
std::vector< wxString > m_variantNames
Definition
job_export_sch_plot.h:73
JOB::FromJson
virtual void FromJson(const nlohmann::json &j)
Definition
job.cpp:60
JOB::ToJson
virtual void ToJson(nlohmann::json &j) const
Definition
job.cpp:67
job_export_sch_plot.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:136
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(VariantRoundTrip)
Definition
test_job_export_sch_plot.cpp:32
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_job_export_sch_plot.cpp
Generated on Sat Feb 21 2026 00:08:11 for KiCad PCB EDA Suite by
1.13.2