KiCad PCB EDA Suite
Loading...
Searching...
No Matches
allegro_block_tests.h
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 3
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/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 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
24#pragma once
25
26#include <cstdint>
27#include <functional>
28#include <iomanip>
29#include <vector>
30
31#include <convert/allegro_db.h>
32
33
34namespace KI_TEST
35{
37
42{
44 std::string m_HeaderDataSource;
46 bool m_Skip;
47
48 friend std::ostream& operator<<( std::ostream& os, const HEADER_TEST_INFO& aTestInfo )
49 {
50 wxString descr = wxString::Format( "Header: %s", aTestInfo.m_HeaderDataSource );
51 os << descr.ToStdString();
52 return os;
53 }
54};
55
60{
62 uint8_t m_BlockType;
66 bool m_Skip;
72 std::string m_DataSource;
73
74 friend std::ostream& operator<<( std::ostream& os, const BLOCK_TEST_INFO& aTestInfo )
75 {
76 wxString msg = wxString::Format( "Block type %#02x at offset %#010zx", aTestInfo.m_BlockType,
77 aTestInfo.m_BlockOffset );
78 os << msg.ToStdString();
79 return os;
80 }
81};
82
83
85{
87 std::string m_BrdName;
89 std::string m_FilePath;
92 // If there is a header test for this board, it will be stored here, else nullptr
93 std::unique_ptr<HEADER_TEST_INFO> m_HeaderTest;
94 // List of block tests for this board
95 std::vector<BLOCK_TEST_INFO> m_BlockTests;
96 // A KiCad board expectation test to run against the parsed board, or nullptr
97 std::unique_ptr<BOARD_EXPECTATION_TEST> m_BrdExpectations;
98};
99
100
107extern void RunAdditionalBlockTest( const std::string& aBoardName, size_t aBlockOffset,
108 const ALLEGRO::BLOCK_BASE& aBlock );
109
117extern void RunAdditionalObjectTest( const std::string& aBoardName, size_t aBlockOffset,
118 const ALLEGRO::DB_OBJ& aDbObj );
119
120
121} // namespace KI_TEST
The base class for all blocks in the main body of an Allegro file.
FMT_VER
The format of an Allego file.
void RunAdditionalObjectTest(const std::string &aBoardName, size_t aBlockOffset, const ALLEGRO::DB_OBJ &aDbObj)
Look up and run any additional ad-hoc tests for a DB_OBJ (parsed and converted block)
void RunAdditionalBlockTest(const std::string &aBoardName, size_t aBlockOffset, const ALLEGRO::BLOCK_BASE &aBlock)
Look up and run any additional ad-hoc tests for a block.
A DB_OBJ represents one object in an Allegro database.
Definition allegro_db.h:168
A complete description of a block test.
uint8_t m_BlockType
The type of the block, as in the first byte.
friend std::ostream & operator<<(std::ostream &os, const BLOCK_TEST_INFO &aTestInfo)
bool m_ExtraDbObjTest
Do we have an additional DB_OBJ-level test to run for this block?
std::string m_DataSource
The the source of the block data (probably a filename)
bool m_ExtraBlockTest
Do we have an additional block-level test to run for this block?
size_t m_BlockOffset
The offset within the board file where this block is located (used for error messages)
bool m_Skip
Whether to skip this test while parsers don't support a certain format.
std::string m_BrdName
The name of the board being tested, used for error messages and test context.
std::unique_ptr< BOARD_EXPECTATION_TEST > m_BrdExpectations
std::unique_ptr< HEADER_TEST_INFO > m_HeaderTest
ALLEGRO::FMT_VER m_FormatVersion
The version of the Allegro format that this board is in.
std::vector< BLOCK_TEST_INFO > m_BlockTests
std::string m_FilePath
The filename of the board being tested.
A header block, along with the expected result of parsing it.
std::string m_HeaderDataSource
Source of the header data to be loaded and tested.
friend std::ostream & operator<<(std::ostream &os, const HEADER_TEST_INFO &aTestInfo)
bool m_Skip
Whether to skip this test while parsers don't support a certain format.