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;
68 std::string m_DataSource;
70 std::function<void( const ALLEGRO::BLOCK_BASE& )> m_ValidateFunc;
71
72 friend std::ostream& operator<<( std::ostream& os, const BLK_TEST_INFO& aTestInfo )
73 {
74 wxString msg = wxString::Format( "Block type %#02x at offset %#010zx", aTestInfo.m_BlockType,
75 aTestInfo.m_BlockOffset );
76 os << msg.ToStdString();
77 return os;
78 }
79};
80
81
83{
85 std::string m_BrdName;
87 std::string m_FilePath;
90 // If there is a header test for this board, it will be stored here, else nullptr
91 std::unique_ptr<HEADER_TEST_INFO> m_HeaderTest;
92 // List of block tests for this board
93 std::vector<BLK_TEST_INFO> m_BlockTests;
94 // A KiCad board expectation test to run against the parsed board, or nullptr
95 std::unique_ptr<BOARD_EXPECTATION_TEST> m_BrdExpectations;
96};
97
98
105extern void RunAdditionalBlockTest( const std::string& aBoardName, size_t aBlockOffset,
106 const ALLEGRO::BLOCK_BASE& aBlock );
107
115extern void RunAdditionalObjectTest( const std::string& aBoardName, size_t aBlockOffset,
116 const ALLEGRO::DB_OBJ& aDbObj );
117
118
119} // 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:162
A single block of test data, along with the expected result of parsing it.
std::function< void(const ALLEGRO::BLOCK_BASE &)> m_ValidateFunc
An optional function to validate the contents of the parsed block if parsing is expected to succeed.
std::string m_DataSource
The raw bytes of the block, as copied from the file.
size_t m_BlockOffset
The offset within the board file where this block is located (used for error messages)
uint8_t m_BlockType
The type of the block, as in the first byte.
bool m_Skip
Whether to skip this test while parsers don't support a certain format.
friend std::ostream & operator<<(std::ostream &os, const BLK_TEST_INFO &aTestInfo)
std::string m_BrdName
The name of the board being tested, used for error messages and test context.
std::vector< BLK_TEST_INFO > m_BlockTests
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::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.