KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_zone.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) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
26
27#include <board.h>
28#include <zone.h>
29
30
32{
34};
35
36
37BOOST_FIXTURE_TEST_SUITE( Zone, ZONE_TEST_FIXTURE )
38
40{
41 ZONE zone( &m_board );
42
43 zone.SetLayer( F_Cu );
44
45 BOOST_TEST( zone.GetLayer() == F_Cu );
46 BOOST_TEST( zone.GetLayer() == zone.GetFirstLayer() );
47
48 BOOST_TEST( zone.IsOnCopperLayer() == true );
49}
50
51BOOST_AUTO_TEST_CASE( MultipleLayers )
52{
53 ZONE zone( &m_board );
54
55 zone.SetLayerSet( { F_Cu, B_Cu } );
56
57 // There is no "the" layer in a multi-layer zone
59 // ... but there is a first layer
60 BOOST_TEST( zone.GetFirstLayer() == F_Cu );
61
62 BOOST_TEST( zone.IsOnCopperLayer() == true );
63}
64
71BOOST_AUTO_TEST_CASE( RescuedLayers )
72{
73 ZONE zone( &m_board );
74
75 zone.SetLayer( Rescue );
76
77 BOOST_TEST( zone.GetLayer() == Rescue );
78 BOOST_TEST( zone.GetLayer() == zone.GetFirstLayer() );
79
80 BOOST_TEST( zone.IsOnCopperLayer() == false );
81}
82
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:260
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:298
void SetLayerSet(const LSET &aLayerSet) override
Definition: zone.cpp:304
bool IsOnCopperLayer() const override
Definition: zone.cpp:292
PCB_LAYER_ID GetFirstLayer() const
Definition: zone.cpp:270
@ B_Cu
Definition: layer_ids.h:65
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ Rescue
Definition: layer_ids.h:121
@ F_Cu
Definition: layer_ids.h:64
BOOST_TEST(box.ClosestPointTo(VECTOR2D(0, 0))==VECTOR2D(1, 2))
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(SingleLayer)
Definition: test_zone.cpp:39