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
>
25
#include <
qa_utils/wx_utils/unit_test_utils.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
30
BOOST_AUTO_TEST_SUITE
( ERCLibSymbolFieldPosition )
31
32
33
BOOST_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
44
constexpr
int
flags =
SCH_ITEM::COMPARE_FLAGS::EQUALITY
|
SCH_ITEM::COMPARE_FLAGS::ERC
;
45
46
int
result
= original.
Compare
(
moved
, flags );
47
48
BOOST_CHECK_MESSAGE
(
result
== 0,
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
55
BOOST_AUTO_TEST_SUITE_END
()
EDA_TEXT::SetTextPos
void SetTextPos(const VECTOR2I &aPoint)
Definition
eda_text.cpp:576
LIB_SYMBOL
Define a library symbol object.
Definition
lib_symbol.h:79
LIB_SYMBOL::Compare
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
Definition
lib_symbol.cpp:2031
LIB_SYMBOL::GetValueField
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition
lib_symbol.h:329
SCH_FIELD::SetText
void SetText(const wxString &aText) override
Definition
sch_field.cpp:1127
SCH_ITEM::ERC
@ ERC
Definition
sch_item.h:706
SCH_ITEM::EQUALITY
@ EQUALITY
Definition
sch_item.h:705
lib_symbol.h
sch_field.h
sch_item.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
moved
bool moved
Definition
test_ki_any.cpp:398
BOOST_CHECK_MESSAGE
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
result
wxString result
Test unit parsing edge cases and error handling.
Definition
test_text_eval_numeric_compat.cpp:598
unit_test_utils.h
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:683
src
qa
tests
eeschema
erc
test_erc_lib_symbol_field_position.cpp
Generated on Thu Jun 18 2026 00:07:05 for KiCad PCB EDA Suite by
1.13.2