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>
21
#include <
jobs/job_export_sch_plot.h
>
22
#include <nlohmann/json.hpp>
23
24
25
BOOST_AUTO_TEST_SUITE
( JobExportSchPlot )
26
27
28
BOOST_AUTO_TEST_CASE
( VariantRoundTrip )
29
{
30
JOB_EXPORT_SCH_PLOT_PDF
job;
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
38
JOB_EXPORT_SCH_PLOT_PDF
loaded;
39
loaded.
FromJson
( j );
40
41
BOOST_CHECK( loaded.
m_variant
== wxS(
"var2"
) );
42
}
43
44
45
BOOST_AUTO_TEST_CASE
( EmptyVariantRoundTrip )
46
{
47
JOB_EXPORT_SCH_PLOT_PDF
job;
48
49
nlohmann::json j;
50
job.
ToJson
( j );
51
52
BOOST_CHECK_EQUAL
( j.value(
"variant_name"
,
""
),
""
);
53
54
JOB_EXPORT_SCH_PLOT_PDF
loaded;
55
loaded.
FromJson
( j );
56
57
BOOST_CHECK( loaded.
m_variant
.IsEmpty() );
58
BOOST_CHECK( loaded.
m_variantNames
.empty() );
59
}
60
61
62
BOOST_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
73
JOB_EXPORT_SCH_PLOT_PDF
loaded;
74
loaded.
FromJson
( j );
75
76
BOOST_CHECK( loaded.
m_variant
== wxS(
"var2"
) );
77
BOOST_CHECK( loaded.
m_variantNames
.empty() );
78
}
79
80
81
BOOST_AUTO_TEST_SUITE_END
()
JOB_EXPORT_SCH_PLOT_PDF
Definition
job_export_sch_plot.h:79
JOB_EXPORT_SCH_PLOT::m_variant
wxString m_variant
Definition
job_export_sch_plot.h:57
JOB_EXPORT_SCH_PLOT::m_variantNames
std::vector< wxString > m_variantNames
Definition
job_export_sch_plot.h:74
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:71
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:28
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_job_export_sch_plot.cpp
Generated on Fri Jun 26 2026 00:05:43 for KiCad PCB EDA Suite by
1.13.2