KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_kiid.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 (C) 1992-2021 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 along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21#include <kiid.h>
22#include <wx/string.h>
23
24
26
27
29{
31
32 KIID a0;
33 KIID b0;
34 KIID c0;
35 KIID d0;
36
38
39 KIID a;
40 BOOST_CHECK_EQUAL( a.Hash(), a0.Hash() );
41
42 KIID b;
43 BOOST_CHECK_EQUAL( b.Hash(), b0.Hash() );
44
45 KIID c;
46 BOOST_CHECK_EQUAL( c.Hash(), c0.Hash() );
47
48 KIID d;
49 BOOST_CHECK_EQUAL( d.Hash(), d0.Hash() );
50}
51
52
53BOOST_AUTO_TEST_CASE( KiidPathTest )
54{
55 KIID a, b, c, d;
56
57 KIID_PATH path1;
58 KIID_PATH path2;
59
60 path1.push_back( a );
61 path1.push_back( b );
62 path1.push_back( c );
63 path1.push_back( d );
64
65 path2.push_back( b );
66 path2.push_back( c );
67 path2.push_back( d );
68
69 BOOST_CHECK( path1.EndsWith( path2 ) == true );
70 BOOST_CHECK( path2.EndsWith( path1 ) == false );
71}
72
73
74BOOST_AUTO_TEST_CASE( LegacyTimestamp )
75{
76 timestamp_t ts_a = 0xAABBCCDD;
77 timestamp_t ts_b = 0x00000012;
78
79 wxString str_a( wxS( "AABBCCDD" ) );
80 wxString str_b( wxS( "00000012" ) );
81
82 KIID a( ts_a );
83 KIID b( ts_b );
84
85 BOOST_CHECK( a.AsLegacyTimestamp() == ts_a );
87
88 BOOST_CHECK( b.AsLegacyTimestamp() == ts_b );
90
91 BOOST_CHECK( KIID( str_a ).AsLegacyTimestamp() == ts_a );
92 BOOST_CHECK( KIID( str_b ).AsLegacyTimestamp() == ts_b );
93
94 BOOST_CHECK( KIID( str_a ).AsLegacyTimestampString() == str_a );
95 BOOST_CHECK( KIID( str_b ).AsLegacyTimestampString() == str_b );
96}
97
98
99BOOST_AUTO_TEST_SUITE_END()
bool EndsWith(const KIID_PATH &aPath) const
Test if aPath from the last path towards the first path.
Definition: kiid.cpp:335
Definition: kiid.h:49
static void SeedGenerator(unsigned int aSeed)
Re-initialize the UUID generator with a given seed (for testing or QA purposes)
Definition: kiid.cpp:294
size_t Hash() const
Definition: kiid.cpp:226
wxString AsLegacyTimestampString() const
Definition: kiid.cpp:258
timestamp_t AsLegacyTimestamp() const
Definition: kiid.cpp:213
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: kiid.h:46
BOOST_CHECK(box.ClosestPointTo(VECTOR2D(0, 0))==VECTOR2D(1, 2))
Test suite for KiCad math code.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(Seeding)
Definition: test_kiid.cpp:28