KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_layer_ids.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) 2023 Wayne Stambaugh <
[email protected]
>
5
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6
*
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation, either version 3 of the License, or (at your
10
* option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#include <boost/test/unit_test.hpp>
22
#include <
layer_ids.h
>
23
#include <
lset.h
>
24
#include <
lseq.h
>
25
26
27
BOOST_AUTO_TEST_SUITE
( LayerIds )
28
29
30
BOOST_AUTO_TEST_CASE
( LseqTestLayers )
31
{
32
LSET
allLayers =
LSET::AllLayersMask
();
33
LSEQ
seq1 = allLayers.
SeqStackupTop2Bottom
();
34
35
BOOST_CHECK_EQUAL
( seq1.
TestLayers
(
PCB_LAYER_ID::F_Cu
,
PCB_LAYER_ID::F_Cu
), 0 );
36
BOOST_CHECK_GT( seq1.
TestLayers
(
PCB_LAYER_ID::F_Cu
,
PCB_LAYER_ID::In1_Cu
), 0 );
37
BOOST_CHECK_LT( seq1.
TestLayers
(
PCB_LAYER_ID::In1_Cu
,
PCB_LAYER_ID::F_Cu
), 0 );
38
39
// Pretend like inner copper layer one is the currently selected layer.
40
LSEQ
seq2 = allLayers.
SeqStackupTop2Bottom
(
PCB_LAYER_ID::In1_Cu
);
41
BOOST_CHECK_LT( seq2.
TestLayers
(
PCB_LAYER_ID::F_Cu
,
PCB_LAYER_ID::In1_Cu
), 0 );
42
BOOST_CHECK_GT( seq2.
TestLayers
(
PCB_LAYER_ID::In1_Cu
,
PCB_LAYER_ID::F_Cu
), 0 );
43
}
44
45
46
BOOST_AUTO_TEST_CASE
( CopperLayers )
47
{
48
BOOST_TEST
(
IsCopperLayer
(
PCB_LAYER_ID::F_Cu
) );
49
BOOST_TEST
(
IsCopperLayer
(
PCB_LAYER_ID::B_Cu
) );
50
BOOST_TEST
(
IsCopperLayer
(
PCB_LAYER_ID::In1_Cu
) );
51
BOOST_TEST
( !
IsCopperLayer
(
PCB_LAYER_ID::UNSELECTED_LAYER
) );
52
BOOST_TEST
( !
IsCopperLayer
(
PCB_LAYER_ID::UNDEFINED_LAYER
) );
53
BOOST_TEST
( !
IsCopperLayer
(
PCB_LAYER_ID::F_SilkS
) );
54
55
BOOST_TEST
( !
IsCopperLayerLowerThan
(
PCB_LAYER_ID::F_Cu
,
PCB_LAYER_ID::B_Cu
) );
56
BOOST_TEST
(
IsCopperLayerLowerThan
(
PCB_LAYER_ID::In1_Cu
,
PCB_LAYER_ID::F_Cu
) );
57
BOOST_TEST
(
IsCopperLayerLowerThan
(
PCB_LAYER_ID::In2_Cu
,
PCB_LAYER_ID::F_Cu
) );
58
BOOST_TEST
(
IsCopperLayerLowerThan
(
PCB_LAYER_ID::B_Cu
,
PCB_LAYER_ID::F_Cu
) );
59
BOOST_TEST
( !
IsCopperLayerLowerThan
(
PCB_LAYER_ID::In1_Cu
,
PCB_LAYER_ID::B_Cu
) );
60
BOOST_TEST
( !
IsCopperLayerLowerThan
(
PCB_LAYER_ID::B_Cu
,
PCB_LAYER_ID::B_Cu
) );
61
}
62
63
64
BOOST_AUTO_TEST_CASE
( FlipLset )
65
{
66
LSET
front( {
F_Cu
,
In1_Cu
,
In2_Cu
} );
67
LSET
back( {
B_Cu
,
In3_Cu
,
In4_Cu
} );
68
69
front.
FlipStandardLayers
( 6 );
70
back.
FlipStandardLayers
( 6 );
71
72
BOOST_TEST
( front.compare(
LSET
{ B_Cu, In3_Cu, In4_Cu } ) == 0 );
73
BOOST_TEST
( back.compare(
LSET
{ F_Cu, In1_Cu, In2_Cu } ) == 0 );
74
}
75
76
77
BOOST_AUTO_TEST_SUITE_END
()
LSEQ
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition
lseq.h:47
LSEQ::TestLayers
int TestLayers(PCB_LAYER_ID aRhs, PCB_LAYER_ID aLhs) const
Definition
lseq.cpp:27
LSET
LSET is a set of PCB_LAYER_IDs.
Definition
lset.h:37
LSET::FlipStandardLayers
LSET & FlipStandardLayers(int aCopperLayersCount=0)
Flip the layers in this set.
Definition
lset.cpp:468
LSET::SeqStackupTop2Bottom
LSEQ SeqStackupTop2Bottom(PCB_LAYER_ID aSelectedLayer=UNDEFINED_LAYER) const
Generate a sequence of layers that represent a top to bottom stack of this set of layers.
Definition
lset.cpp:326
LSET::AllLayersMask
static const LSET & AllLayersMask()
Definition
lset.cpp:624
layer_ids.h
IsCopperLayerLowerThan
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
Definition
layer_ids.h:820
IsCopperLayer
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition
layer_ids.h:674
B_Cu
@ B_Cu
Definition
layer_ids.h:65
In2_Cu
@ In2_Cu
Definition
layer_ids.h:67
UNSELECTED_LAYER
@ UNSELECTED_LAYER
Definition
layer_ids.h:62
F_SilkS
@ F_SilkS
Definition
layer_ids.h:100
In4_Cu
@ In4_Cu
Definition
layer_ids.h:69
UNDEFINED_LAYER
@ UNDEFINED_LAYER
Definition
layer_ids.h:61
In1_Cu
@ In1_Cu
Definition
layer_ids.h:66
In3_Cu
@ In3_Cu
Definition
layer_ids.h:68
F_Cu
@ F_Cu
Definition
layer_ids.h:64
lseq.h
lset.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:134
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_TEST
BOOST_TEST(contains==c.ExpectedContains)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(LseqTestLayers)
Definition
test_layer_ids.cpp:30
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_layer_ids.cpp
Generated on Sun Sep 21 2025 01:05:32 for KiCad PCB EDA Suite by
1.13.2