KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sim_decomposition.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 <
qa_utils/wx_utils/unit_test_utils.h
>
21
#include <
sim/sim_model_multiunit.h
>
22
23
24
BOOST_AUTO_TEST_SUITE
( SimDecomposition )
25
26
27
BOOST_AUTO_TEST_CASE
( ParseRepeatWithShared )
28
{
29
SIM_DECOMPOSITION
dec =
SIM_DECOMPOSITION::Parse
( wxS(
"mode=repeat shared=VCC,VEE"
) );
30
31
BOOST_CHECK( dec.
mode
==
SIM_DECOMPOSITION::MODE::REPEAT_PER_UNIT
);
32
BOOST_REQUIRE_EQUAL( dec.
sharedModelPins
.size(), 2 );
33
BOOST_CHECK_EQUAL
( dec.
sharedModelPins
[0], wxS(
"VCC"
) );
34
BOOST_CHECK_EQUAL
( dec.
sharedModelPins
[1], wxS(
"VEE"
) );
35
}
36
37
38
BOOST_AUTO_TEST_CASE
( FormatRepeatWithShared )
39
{
40
SIM_DECOMPOSITION
dec;
41
dec.
mode
=
SIM_DECOMPOSITION::MODE::REPEAT_PER_UNIT
;
42
dec.
sharedModelPins
= { wxS(
"VCC"
), wxS(
"VEE"
) };
43
44
BOOST_CHECK_EQUAL
( dec.
Format
(), wxS(
"mode=repeat shared=VCC,VEE"
) );
45
}
46
47
48
BOOST_AUTO_TEST_CASE
( RoundTrip )
49
{
50
const
wxString canonical = wxS(
"mode=repeat shared=VCC,VEE"
);
51
52
BOOST_CHECK_EQUAL
(
SIM_DECOMPOSITION::Parse
( canonical ).
Format
(), canonical );
53
}
54
55
56
BOOST_AUTO_TEST_CASE
( RepeatWithoutShared )
57
{
58
SIM_DECOMPOSITION
dec =
SIM_DECOMPOSITION::Parse
( wxS(
"mode=repeat"
) );
59
60
BOOST_CHECK( dec.
mode
==
SIM_DECOMPOSITION::MODE::REPEAT_PER_UNIT
);
61
BOOST_CHECK( dec.
sharedModelPins
.empty() );
62
BOOST_CHECK_EQUAL
( dec.
Format
(), wxS(
"mode=repeat"
) );
63
}
64
65
66
BOOST_AUTO_TEST_CASE
( EmptyIsWholeDevice )
67
{
68
SIM_DECOMPOSITION
dec =
SIM_DECOMPOSITION::Parse
( wxEmptyString );
69
70
BOOST_CHECK( dec.
mode
==
SIM_DECOMPOSITION::MODE::WHOLE_DEVICE
);
71
BOOST_CHECK( dec.
Format
().IsEmpty() );
72
}
73
74
75
BOOST_AUTO_TEST_CASE
( UnknownModeIsWholeDevice )
76
{
77
SIM_DECOMPOSITION
dec =
SIM_DECOMPOSITION::Parse
( wxS(
"mode=bogus shared=VCC"
) );
78
79
BOOST_CHECK( dec.
mode
==
SIM_DECOMPOSITION::MODE::WHOLE_DEVICE
);
80
BOOST_CHECK( dec.
Format
().IsEmpty() );
81
}
82
83
84
BOOST_AUTO_TEST_CASE
( ExplicitWholeDeviceFormatsEmpty )
85
{
86
SIM_DECOMPOSITION
dec =
SIM_DECOMPOSITION::Parse
( wxS(
"mode=whole"
) );
87
88
BOOST_CHECK( dec.
mode
==
SIM_DECOMPOSITION::MODE::WHOLE_DEVICE
);
89
BOOST_CHECK( dec.
Format
().IsEmpty() );
90
}
91
92
93
BOOST_AUTO_TEST_SUITE_END
()
Format
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition
ptree.cpp:194
sim_model_multiunit.h
SIM_DECOMPOSITION
Per-component decomposition descriptor stored in the Sim.Decomposition field.
Definition
sim_model_multiunit.h:58
SIM_DECOMPOSITION::Parse
static SIM_DECOMPOSITION Parse(const wxString &aField)
Definition
sim_model_multiunit.cpp:32
SIM_DECOMPOSITION::mode
MODE mode
Definition
sim_model_multiunit.h:65
SIM_DECOMPOSITION::sharedModelPins
std::vector< wxString > sharedModelPins
Definition
sim_model_multiunit.h:66
SIM_DECOMPOSITION::Format
wxString Format() const
Definition
sim_model_multiunit.cpp:71
SIM_DECOMPOSITION::MODE::REPEAT_PER_UNIT
@ REPEAT_PER_UNIT
Definition
sim_model_multiunit.h:62
SIM_DECOMPOSITION::MODE::WHOLE_DEVICE
@ WHOLE_DEVICE
Definition
sim_model_multiunit.h:61
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(ParseRepeatWithShared)
Definition
test_sim_decomposition.cpp:27
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
spice
test_sim_decomposition.cpp
Generated on Fri Jun 26 2026 00:05:45 for KiCad PCB EDA Suite by
1.13.2