KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_bus_parsing.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
23
24
25BOOST_AUTO_TEST_SUITE( BusParsing )
26
27
28BOOST_AUTO_TEST_CASE( ParsesFormattedVectorBus )
29{
30 wxString name;
31 std::vector<wxString> members;
32
33 BOOST_CHECK( NET_SETTINGS::ParseBusVector( wxS( "D_{[1..2]}" ), &name, &members ) );
34 BOOST_CHECK_EQUAL( name, wxS( "D" ) );
35
36 std::vector<wxString> expected = { wxS( "D1" ), wxS( "D2" ) };
37
38 BOOST_CHECK_EQUAL_COLLECTIONS( members.begin(), members.end(), expected.begin(), expected.end() );
39}
40
41
42BOOST_AUTO_TEST_CASE( ParsesFormattedGroupWithVectorMember )
43{
44 wxString name;
45 std::vector<wxString> members;
46
47 BOOST_CHECK( NET_SETTINGS::ParseBusGroup( wxS( "MEM{D_{[1..2]} ~{LATCH}}" ), &name, &members ) );
48 BOOST_CHECK_EQUAL( name, wxS( "MEM" ) );
49
50 std::vector<wxString> expected = { wxS( "D[1..2]" ), wxS( "LATCH" ) };
51
52 BOOST_CHECK_EQUAL_COLLECTIONS( members.begin(), members.end(), expected.begin(), expected.end() );
53}
54
55
const char * name
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(ParsesFormattedVectorBus)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_EQUAL(result, "25.4")