KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_fab_stackup.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
22#include <boost/test/unit_test.hpp>
23
24#include <board.h>
27
28#include <algorithm>
29
30
31BOOST_AUTO_TEST_CASE( FabStackupSnapshotsRealBoard )
32{
34 + "ipc2581/dielectric-sublayer.kicad_pcb" );
35 BOOST_REQUIRE( board );
36
37 BOARD_DESIGN_SETTINGS& settings = board->GetDesignSettings();
38 BOARD_STACKUP before = settings.GetStackupDescriptor();
39 std::vector<BOARD_STACKUP_ITEM*> beforeItems = settings.GetStackupDescriptor().GetList();
40 BOARD_STACKUP expected = before;
41 expected.SynchronizeWithBoard( &settings );
42
43 FAB_STACKUP snapshot( *board );
44 BOOST_CHECK( snapshot.Stackup() == expected );
45
46 for( const BOARD_STACKUP_ITEM* item : snapshot.Stackup().GetList() )
47 {
48 BOOST_CHECK( std::ranges::none_of( beforeItems,
49 [&]( const BOARD_STACKUP_ITEM* aSource )
50 {
51 return aSource == item;
52 } ) );
53 }
54
55 BOOST_CHECK_EQUAL( snapshot.Thickness(), expected.BuildBoardThicknessFromStackup() );
56 BOOST_CHECK( settings.GetStackupDescriptor() == before );
57 BOOST_CHECK( settings.GetStackupDescriptor().GetList() == beforeItems );
58
59 for( const BOARD_STACKUP_ITEM* item : snapshot.Stackup().GetList() )
60 {
61 if( item->GetBrdLayerId() != UNDEFINED_LAYER )
62 BOOST_CHECK( snapshot.ItemForLayer( item->GetBrdLayerId() ) != nullptr );
63 }
64
65 BOOST_CHECK( snapshot.ItemForLayer( UNDEFINED_LAYER ) == nullptr );
66}
General utilities for PCB file IO for QA programs.
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
Manage one layer needed to make a physical board.
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
Board stackup snapshot synchronized without changing the source board.
Definition fab_stackup.h:29
const BOARD_STACKUP & Stackup() const
Definition fab_stackup.h:38
int Thickness() const
Definition fab_stackup.h:42
const BOARD_STACKUP_ITEM * ItemForLayer(PCB_LAYER_ID aLayer) const
@ UNDEFINED_LAYER
Definition layer_ids.h:57
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
BOOST_AUTO_TEST_CASE(FabStackupSnapshotsRealBoard)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_EQUAL(result, "25.4")