KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_connectivity_publish.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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
22
23using namespace SCH_CONNECTIVITY;
24
25BOOST_AUTO_TEST_SUITE( ConnectivityPublish )
26
27BOOST_AUTO_TEST_CASE( GroupSuffixPreservesQuotedAndEscapedPrefixes )
28{
29 const std::vector<std::pair<wxString, wxString>> cases{
30 { "MY\\ BUS{A B}", "MY\\ BUS_1{A B}" },
31 { "\"MY BUS\"{A B}", "\"MY BUS\"_1{A B}" },
32 { "R{slash}W\\ BUS{A}", "R{slash}W\\ BUS_1{A}" },
33 { "I^{2}C\\ BUS{A}", "I^{2}C\\ BUS_1{A}" },
34 { "G{lt}H{A}", "G{lt}H_1{A}" },
35 { "G{return}{A}", "G{return}_1{A}" },
36 { "{dblquote}MY BUS{dblquote}{A}", "{dblquote}MY BUS{dblquote}_1{A}" },
37 { "G{A}", "G_1{A}" }
38 };
39
40 for( const auto& [text, expected] : cases )
41 {
43 {
44 const auto schema = BUS_SCHEMA::Parse( text );
45 BOOST_REQUIRE( schema );
46 BOOST_CHECK_EQUAL( ApplyNameSuffix( text, &*schema, 0 ), text );
47 const wxString rendered = ApplyNameSuffix( text, &*schema, 1 );
48 BOOST_CHECK_EQUAL( rendered, expected );
49 const auto parsed = BUS_SCHEMA::Parse( rendered );
50 BOOST_REQUIRE( parsed );
51 BOOST_CHECK_EQUAL( parsed->prefix, schema->prefix + "_1" );
52 BOOST_REQUIRE_EQUAL( parsed->leaves.size(), schema->leaves.size() );
53
54 for( size_t i = 0; i < schema->leaves.size(); ++i )
55 {
56 const wxString name = schema->prefix + "_1"
57 + schema->leaves[i].name.Mid( schema->prefix.length() );
58 BOOST_CHECK_EQUAL( parsed->leaves[i].name, name );
59 }
60 }
61 }
62}
63
const char * name
Value keys and the key session of the schematic connectivity engine.
wxString ApplyNameSuffix(const wxString &aName, const BUS_SCHEMA *aSchema, uint32_t aSuffix)
Add "_N" to aName.
static std::optional< BUS_SCHEMA > Parse(const wxString &aText, const BUS_ALIASES &aAliases={})
Parse a vector or group bus text.
Definition conn_bus.cpp:186
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")