KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_erc_lib_symbol_field_position.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 3
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, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
21#include <boost/test/unit_test.hpp>
22#include <lib_symbol.h>
23#include <sch_field.h>
24#include <sch_item.h>
26
27// Issue #24657: a pure field position change must not trip the ERC lib-symbol
28// mismatch check, matching the behavior when the field is moved in the schematic.
29
30BOOST_AUTO_TEST_SUITE( ERCLibSymbolFieldPosition )
31
32
33BOOST_AUTO_TEST_CASE( Issue24657FieldPositionIgnoredForERC )
34{
35 LIB_SYMBOL original( "R" );
36
37 original.GetValueField().SetText( wxS( "R" ) );
38 original.GetValueField().SetTextPos( VECTOR2I( 0, 0 ) );
39
40 // Move only the value field's position, leaving everything else untouched.
41 LIB_SYMBOL moved( original );
42 moved.GetValueField().SetTextPos( VECTOR2I( 0, 254000 ) );
43
45
46 int result = original.Compare( moved, flags );
47
49 "ERC lib-symbol comparison flagged a pure field position change "
50 "(Compare returned " << result << "); expected 0 to match the "
51 "schematic-side move behavior (issue #24657)." );
52}
53
54
void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:576
Define a library symbol object.
Definition lib_symbol.h:79
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:329
void SetText(const wxString &aText) override
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
bool moved
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683