KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_issue14447_arc_connection.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
31
32#include <boost/test/unit_test.hpp>
34
35#include <memory>
36
38
39
41{
42 std::string GetTestFile()
43 {
44 return KI_TEST::GetEeschemaTestDataDir() + "io/cadstar/issue14447_arc_connection.csa";
45 }
46};
47
48
49BOOST_FIXTURE_TEST_SUITE( CadstarSchArcConnection, ARC_CONNECTION_FIXTURE )
50
51
52BOOST_AUTO_TEST_CASE( ParseConnectionWithArc )
53{
54 using PARSER = CADSTAR_SCH_ARCHIVE_PARSER;
55
56 std::unique_ptr<XNODE> root( PARSER::LoadArchiveFile( GetTestFile(), wxT( "CADSTARSCM" ) ) );
57 BOOST_REQUIRE( root );
58
59 // Walk down to the single CONN node the fixture file holds.
60 XNODE* connNode = nullptr;
61
62 for( XNODE* schematic = root->GetChildren(); schematic && !connNode;
63 schematic = schematic->GetNext() )
64 {
65 if( schematic->GetName() != wxT( "SCHEMATIC" ) )
66 continue;
67
68 for( XNODE* net = schematic->GetChildren(); net && !connNode; net = net->GetNext() )
69 {
70 if( net->GetName() != wxT( "NET" ) )
71 continue;
72
73 for( XNODE* child = net->GetChildren(); child; child = child->GetNext() )
74 {
75 if( child->GetName() == wxT( "CONN" ) )
76 {
77 connNode = child;
78 break;
79 }
80 }
81 }
82 }
83
84 BOOST_REQUIRE( connNode );
85
86 PARSER::PARSER_CONTEXT context;
87 PARSER::NET_SCH::CONNECTION_SCH conn;
88
89 // The whole bug is here. With the path parsed as plain points the ACWARC child made parsing
90 // abort with IO_ERROR( "Unknown node 'ACWARC' in 'PATH'" ). It must now parse cleanly.
91 BOOST_REQUIRE_NO_THROW( conn.Parse( connNode, &context ) );
92
93 // Two straight points, the arc, and the closing straight point must all be retained.
94 BOOST_REQUIRE_EQUAL( conn.Path.size(), 4 );
95
96 const CADSTAR_ARCHIVE_PARSER::VERTEX& arc = conn.Path[2];
97
99
100 // CADSTAR emits (ACWARC (PT centre) (PT end)); the parser keeps the first as the arc centre
101 // and the second as its end point.
102 BOOST_CHECK_EQUAL( arc.Center.x, 10033000 );
103 BOOST_CHECK_EQUAL( arc.Center.y, 8763000 );
104 BOOST_CHECK_EQUAL( arc.End.x, 11430000 );
105 BOOST_CHECK_EQUAL( arc.End.y, 8763000 );
106
107 // The path must terminate at the final straight point of the connection.
108 BOOST_CHECK_EQUAL( conn.Path[3].End.x, 11430000 );
109 BOOST_CHECK_EQUAL( conn.Path[3].End.y, 10160000 );
110}
111
112
Represents a CADSTAR Schematic Archive (*.csa) file.
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition xnode.h:67
XNODE * GetChildren() const
Definition xnode.h:97
XNODE * GetNext() const
Definition xnode.h:102
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
Represents a vertex in a shape.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")