KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_teardrop_uuid.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 2
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, see <https://www.gnu.org/licenses/>.
18
*/
19
26
27
#include <
qa_utils/wx_utils/unit_test_utils.h
>
28
29
#include <
kiid.h
>
30
31
32
BOOST_AUTO_TEST_SUITE
( TeardropUUID )
33
34
35
BOOST_AUTO_TEST_CASE
( CombineTrackAndPadUuids )
36
{
37
// Simulate the teardrop UUID generation: combine track and pad UUIDs
38
KIID
trackUuid;
39
KIID
padUuid;
40
41
KIID
teardropUuid =
KIID::Combine
( trackUuid, padUuid );
42
43
// The combined UUID should be different from both inputs
44
BOOST_CHECK( teardropUuid != trackUuid );
45
BOOST_CHECK( teardropUuid != padUuid );
46
47
// The same inputs should always produce the same output
48
KIID
teardropUuid2 =
KIID::Combine
( trackUuid, padUuid );
49
BOOST_CHECK_EQUAL
( teardropUuid.
AsString
(), teardropUuid2.
AsString
() );
50
}
51
52
53
BOOST_AUTO_TEST_CASE
( MaskUuidIsIncrementedFromTeardropUuid )
54
{
55
// Teardrop masks use the combined UUID, then increment to differentiate
56
KIID
trackUuid;
57
KIID
padUuid;
58
59
KIID
teardropUuid =
KIID::Combine
( trackUuid, padUuid );
60
61
KIID
maskUuid =
KIID::Combine
( trackUuid, padUuid );
62
maskUuid.
Increment
();
63
64
// The mask UUID should be different from the teardrop UUID
65
BOOST_CHECK( maskUuid != teardropUuid );
66
67
// Both should be deterministic
68
KIID
teardropUuid2 =
KIID::Combine
( trackUuid, padUuid );
69
KIID
maskUuid2 =
KIID::Combine
( trackUuid, padUuid );
70
maskUuid2.
Increment
();
71
72
BOOST_CHECK_EQUAL
( teardropUuid.
AsString
(), teardropUuid2.
AsString
() );
73
BOOST_CHECK_EQUAL
( maskUuid.
AsString
(), maskUuid2.
AsString
() );
74
}
75
76
77
BOOST_AUTO_TEST_CASE
( DifferentTracksProduceDifferentTeardropUuids )
78
{
79
// Two tracks connecting to the same pad should produce different teardrop UUIDs
80
KIID
track1Uuid;
81
KIID
track2Uuid;
82
KIID
padUuid;
83
84
KIID
teardrop1Uuid =
KIID::Combine
( track1Uuid, padUuid );
85
KIID
teardrop2Uuid =
KIID::Combine
( track2Uuid, padUuid );
86
87
// Different tracks should produce different teardrops
88
BOOST_CHECK( teardrop1Uuid != teardrop2Uuid );
89
90
// Each should still be deterministic
91
KIID
teardrop1Uuid2 =
KIID::Combine
( track1Uuid, padUuid );
92
KIID
teardrop2Uuid2 =
KIID::Combine
( track2Uuid, padUuid );
93
94
BOOST_CHECK_EQUAL
( teardrop1Uuid.
AsString
(), teardrop1Uuid2.
AsString
() );
95
BOOST_CHECK_EQUAL
( teardrop2Uuid.
AsString
(), teardrop2Uuid2.
AsString
() );
96
}
97
98
99
BOOST_AUTO_TEST_CASE
( StableAcrossRegenerations )
100
{
101
// Simulates regenerating teardrops: same track+pad should always give same UUID
102
KIID
trackUuid(
"12345678-1234-1234-1234-123456789012"
);
103
KIID
padUuid(
"abcdef01-abcd-abcd-abcd-abcdef012345"
);
104
105
// First generation
106
KIID
teardropUuid1 =
KIID::Combine
( trackUuid, padUuid );
107
108
// Simulate regeneration by computing again
109
KIID
teardropUuid2 =
KIID::Combine
( trackUuid, padUuid );
110
111
// Should be identical
112
BOOST_CHECK_EQUAL
( teardropUuid1.
AsString
(), teardropUuid2.
AsString
() );
113
}
114
115
116
BOOST_AUTO_TEST_SUITE_END
()
KIID
Definition
kiid.h:44
KIID::AsString
wxString AsString() const
Definition
kiid.cpp:242
KIID::Combine
static KIID Combine(const KIID &aFirst, const KIID &aSecond)
Creates a deterministic KIID from two input KIIDs by XORing their underlying UUIDs.
Definition
kiid.cpp:284
KIID::Increment
void Increment()
Generates a deterministic replacement for a given ID.
Definition
kiid.cpp:269
kiid.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()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(CombineTrackAndPadUuids)
Definition
test_teardrop_uuid.cpp:35
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
pcbnew
test_teardrop_uuid.cpp
Generated on Fri Jun 26 2026 00:05:45 for KiCad PCB EDA Suite by
1.13.2