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
22
23
24BOOST_AUTO_TEST_SUITE( SimDecomposition )
25
26
27BOOST_AUTO_TEST_CASE( ParseRepeatWithShared )
28{
29 SIM_DECOMPOSITION dec = SIM_DECOMPOSITION::Parse( wxS( "mode=repeat shared=VCC,VEE" ) );
30
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
38BOOST_AUTO_TEST_CASE( FormatRepeatWithShared )
39{
42 dec.sharedModelPins = { wxS( "VCC" ), wxS( "VEE" ) };
43
44 BOOST_CHECK_EQUAL( dec.Format(), wxS( "mode=repeat shared=VCC,VEE" ) );
45}
46
47
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
56BOOST_AUTO_TEST_CASE( RepeatWithoutShared )
57{
58 SIM_DECOMPOSITION dec = SIM_DECOMPOSITION::Parse( wxS( "mode=repeat" ) );
59
61 BOOST_CHECK( dec.sharedModelPins.empty() );
62 BOOST_CHECK_EQUAL( dec.Format(), wxS( "mode=repeat" ) );
63}
64
65
66BOOST_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
75BOOST_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
84BOOST_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
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
Per-component decomposition descriptor stored in the Sim.Decomposition field.
static SIM_DECOMPOSITION Parse(const wxString &aField)
std::vector< wxString > sharedModelPins
wxString Format() const
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ParseRepeatWithShared)
BOOST_CHECK_EQUAL(result, "25.4")