KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_api_enums.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 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 <magic_enum.hpp>
22#include <import_export.h>
25
26// Common
27#include <api/api_enums.h>
28#include <api/board/board.pb.h>
29#include <api/common/types/enums.pb.h>
30#include <eda_shape.h>
31#include <core/typeinfo.h>
33#include <layer_ids.h>
34#include <pin_type.h>
35#include <stroke_params.h>
37
38// Board-specific
39#include <api/board/board_types.pb.h>
40#include <api/board/board_commands.pb.h>
41#include <api/board/board_jobs.pb.h>
42#include <api/schematic/schematic_jobs.pb.h>
56#include <jobs/job_pcb_render.h>
57#include <drc/drc_item.h>
58#include <drc/drc_rule.h>
59#include <padstack.h>
60#include <pcb_dimension.h>
61#include <pcb_track.h>
62#include <plotprint_opts.h>
64#include <zones.h>
65#include <zone_settings.h>
66
67using namespace kiapi::common;
68
69BOOST_AUTO_TEST_SUITE( ApiEnums )
70
75
80
85
90
95
100
105
110
115
120
125
130
135
137{
138 // VIATYPE::NOT_DEFINED is not mapped
140}
141
146
151
156
161
166
171
176
181
186
191
196
201
206
211
216
221
226
231
232BOOST_AUTO_TEST_CASE( DesignRuleType )
233{
234 using ProtoType = kiapi::board::DrcErrorType;
235
302 {
303 ProtoType proto = ToProtoEnum<PCB_DRC_CODE, ProtoType>( value );
304 BOOST_REQUIRE( proto != ProtoType::DRCET_UNKNOWN );
305 BOOST_CHECK( ( FromProtoEnum<PCB_DRC_CODE, ProtoType>( proto ) == value ) );
306 }
307
308 BOOST_CHECK( ( FromProtoEnum<PCB_DRC_CODE, ProtoType>( ProtoType::DRCET_UNKNOWN )
309 == static_cast<PCB_DRC_CODE>( 0 ) ) );
310}
311
312BOOST_AUTO_TEST_CASE( CustomRuleConstraintType )
313{
314 using ProtoType = kiapi::board::CustomRuleConstraintType;
315
316 for( DRC_CONSTRAINT_T value : magic_enum::enum_values<DRC_CONSTRAINT_T>() )
317 {
318 if( value == NULL_CONSTRAINT )
319 continue;
320
321 ProtoType proto = ToProtoEnum<DRC_CONSTRAINT_T, ProtoType>( value );
322 BOOST_REQUIRE( proto != ProtoType::CRCT_UNKNOWN );
323 BOOST_CHECK( ( FromProtoEnum<DRC_CONSTRAINT_T, ProtoType>( proto ) == value ) );
324 }
325
326 BOOST_CHECK( ( FromProtoEnum<DRC_CONSTRAINT_T, ProtoType>( ProtoType::CRCT_UNKNOWN )
327 == NULL_CONSTRAINT ) );
328}
329
330BOOST_AUTO_TEST_CASE( CustomRuleConstraintOption )
331{
332 using ProtoType = kiapi::board::CustomRuleConstraintOption;
333
334 for( DRC_CONSTRAINT::OPTIONS value : magic_enum::enum_values<DRC_CONSTRAINT::OPTIONS>() )
335 {
337 continue;
338
339 ProtoType proto = ToProtoEnum<DRC_CONSTRAINT::OPTIONS, ProtoType>( value );
340 BOOST_REQUIRE( proto != ProtoType::CRCO_UNKNOWN );
341 BOOST_CHECK( ( FromProtoEnum<DRC_CONSTRAINT::OPTIONS, ProtoType>( proto ) == value ) );
342 }
343}
344
345BOOST_AUTO_TEST_CASE( CustomRuleDisallowType )
346{
347 using ProtoType = kiapi::board::CustomRuleDisallowType;
348
355 {
356 ProtoType proto = ToProtoEnum<DRC_DISALLOW_T, ProtoType>( value );
357 BOOST_REQUIRE( proto != ProtoType::CRDT_UNKNOWN );
358 BOOST_CHECK( ( FromProtoEnum<DRC_DISALLOW_T, ProtoType>( proto ) == value ) );
359 }
360}
361
366
371
376
381
386
391
396
397BOOST_AUTO_TEST_CASE( SvgPaginationMode )
398{
399 using Mode = kiapi::board::jobs::BoardJobPaginationMode;
400
402 == Mode::BJPM_ALL_LAYERS_ONE_PAGE ) );
404 == Mode::BJPM_EACH_LAYER_OWN_FILE ) );
405
406 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_SVG::GEN_MODE, Mode>( Mode::BJPM_ALL_LAYERS_ONE_PAGE )
408 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_SVG::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_FILE )
410 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_SVG::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_PAGE )
412}
413
414BOOST_AUTO_TEST_CASE( DxfPaginationMode )
415{
416 using Mode = kiapi::board::jobs::BoardJobPaginationMode;
417
419 == Mode::BJPM_ALL_LAYERS_ONE_PAGE ) );
421 == Mode::BJPM_EACH_LAYER_OWN_FILE ) );
422
423 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_DXF::GEN_MODE, Mode>( Mode::BJPM_ALL_LAYERS_ONE_PAGE )
425 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_DXF::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_FILE )
427 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_DXF::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_PAGE )
429}
430
435
440
441BOOST_AUTO_TEST_CASE( PsPaginationMode )
442{
443 using Mode = kiapi::board::jobs::BoardJobPaginationMode;
444
446 == Mode::BJPM_ALL_LAYERS_ONE_PAGE ) );
448 == Mode::BJPM_EACH_LAYER_OWN_FILE ) );
449
450 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_PS::GEN_MODE, Mode>( Mode::BJPM_ALL_LAYERS_ONE_PAGE )
452 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_PS::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_FILE )
454 BOOST_CHECK( ( FromProtoEnum<JOB_EXPORT_PCB_PS::GEN_MODE, Mode>( Mode::BJPM_EACH_LAYER_OWN_PAGE )
456}
457
462
467
472
477
482
487
492
497
502
507
512
517
522
527
532
537
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:44
void testEnums(bool aPartiallyMapped=false)
Checks if a KiCad enum has been properly mapped to a Protobuf enum.
PCB_DRC_CODE
Definition drc_item.h:38
@ DRCE_DISABLED_LAYER_ITEM
Definition drc_item.h:72
@ DRCE_SKEW_OUT_OF_RANGE
Definition drc_item.h:105
@ DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE
Definition drc_item.h:107
@ DRCE_CREEPAGE
Definition drc_item.h:45
@ DRCE_HOLE_CLEARANCE
Definition drc_item.h:55
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:99
@ DRCE_ZONES_INTERSECT
Definition drc_item.h:48
@ DRCE_FOOTPRINT_FILTERS
Definition drc_item.h:80
@ DRCE_SILK_MASK_CLEARANCE
Definition drc_item.h:97
@ DRCE_VIA_DIAMETER
Definition drc_item.h:62
@ DRCE_UNCONNECTED_ITEMS
Definition drc_item.h:40
@ DRCE_TRACK_WIDTH
Definition drc_item.h:56
@ DRCE_PADSTACK
Definition drc_item.h:63
@ DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
Definition drc_item.h:110
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition drc_item.h:83
@ DRCE_OVERLAPPING_FOOTPRINTS
Definition drc_item.h:66
@ DRCE_INVALID_OUTLINE
Definition drc_item.h:73
@ DRCE_TRACK_ON_POST_MACHINED_LAYER
Definition drc_item.h:116
@ DRCE_TEXT_ON_EDGECUTS
Definition drc_item.h:43
@ DRCE_DRILL_OUT_OF_RANGE
Definition drc_item.h:61
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:47
@ DRCE_STARVED_THERMAL
Definition drc_item.h:50
@ DRCE_TRACK_SEGMENT_LENGTH
Definition drc_item.h:58
@ DRCE_SCHEMATIC_FIELDS_PARITY
Definition drc_item.h:120
@ DRCE_MISSING_COURTYARD
Definition drc_item.h:67
@ DRCE_TRACK_ANGLE
Definition drc_item.h:57
@ DRCE_TRACK_NOT_CENTERED_ON_VIA
Definition drc_item.h:118
@ DRCE_CLEARANCE
Definition drc_item.h:44
@ DRCE_ISOLATED_COPPER
Definition drc_item.h:49
@ DRCE_GENERIC_ERROR
Definition drc_item.h:91
@ DRCE_MISSING_TUNING_PROFILE
Definition drc_item.h:113
@ DRCE_DRILLED_HOLES_TOO_CLOSE
Definition drc_item.h:53
@ DRCE_ALLOWED_ITEMS
Definition drc_item.h:42
@ DRCE_COPPER_SLIVER
Definition drc_item.h:93
@ DRCE_PTH_IN_COURTYARD
Definition drc_item.h:70
@ DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG
Definition drc_item.h:108
@ DRCE_MICROVIA_DRILL_OUT_OF_RANGE
Definition drc_item.h:65
@ DRCE_SHORTING_ITEMS
Definition drc_item.h:41
@ DRCE_MALFORMED_COURTYARD
Definition drc_item.h:68
@ DRCE_DANGLING_VIA
Definition drc_item.h:51
@ DRCE_PADSTACK_INVALID
Definition drc_item.h:64
@ DRCE_UNRESOLVED_VARIABLE
Definition drc_item.h:88
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition drc_item.h:82
@ DRCE_NONMIRRORED_TEXT_ON_BACK_LAYER
Definition drc_item.h:111
@ DRCE_DUPLICATE_FOOTPRINT
Definition drc_item.h:76
@ DRCE_DANGLING_TRACK
Definition drc_item.h:52
@ DRCE_TEXT_HEIGHT
Definition drc_item.h:101
@ DRCE_ASSERTION_FAILURE
Definition drc_item.h:89
@ DRCE_SOLDERMASK_BRIDGE
Definition drc_item.h:94
@ DRCE_DRILLED_HOLES_COLOCATED
Definition drc_item.h:54
@ DRCE_EXTRA_FOOTPRINT
Definition drc_item.h:77
@ DRCE_SILK_CLEARANCE
Definition drc_item.h:100
@ DRCE_LENGTH_OUT_OF_RANGE
Definition drc_item.h:104
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition drc_item.h:84
@ DRCE_NET_CONFLICT
Definition drc_item.h:78
@ DRCE_MISSING_FOOTPRINT
Definition drc_item.h:75
@ DRCE_PAD_TH_WITH_NO_HOLE
Definition drc_item.h:85
@ DRCE_FOOTPRINT
Definition drc_item.h:86
@ DRCE_GENERIC_WARNING
Definition drc_item.h:90
@ DRCE_TEXT_THICKNESS
Definition drc_item.h:102
@ DRCE_NPTH_IN_COURTYARD
Definition drc_item.h:71
@ DRCE_CONNECTION_WIDTH
Definition drc_item.h:60
@ DRCE_SCHEMATIC_PARITY
Definition drc_item.h:79
@ DRCE_TRACKS_CROSSING
Definition drc_item.h:46
@ DRCE_VIA_COUNT_OUT_OF_RANGE
Definition drc_item.h:106
@ DRCE_ANNULAR_WIDTH
Definition drc_item.h:59
DRC_DISALLOW_T
Definition drc_rule.h:95
@ DRC_DISALLOW_PADS
Definition drc_rule.h:101
@ DRC_DISALLOW_BURIED_VIAS
Definition drc_rule.h:99
@ DRC_DISALLOW_BLIND_VIAS
Definition drc_rule.h:98
@ DRC_DISALLOW_TEXTS
Definition drc_rule.h:103
@ DRC_DISALLOW_ZONES
Definition drc_rule.h:102
@ DRC_DISALLOW_HOLES
Definition drc_rule.h:105
@ DRC_DISALLOW_GRAPHICS
Definition drc_rule.h:104
@ DRC_DISALLOW_THROUGH_VIAS
Definition drc_rule.h:96
@ DRC_DISALLOW_FOOTPRINTS
Definition drc_rule.h:106
@ DRC_DISALLOW_TRACKS
Definition drc_rule.h:100
@ DRC_DISALLOW_MICRO_VIAS
Definition drc_rule.h:97
DRC_CONSTRAINT_T
Definition drc_rule.h:53
@ NULL_CONSTRAINT
Definition drc_rule.h:54
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
Class ZONE_SETTINGS used to handle zones parameters in dialogs.