47 if( c->GetConstraintType() == aType )
63 auto board1 = std::make_unique<BOARD>();
71 board1->Add( parallel );
85 auto path = std::filesystem::temp_directory_path() /
"constraint_roundtrip_tst.kicad_pcb";
108 BOOST_CHECK_CLOSE( *dim2->
GetValue(), 10.0 *
MM, 1e-6 );
116 auto board1 = std::make_unique<BOARD>();
131 KIID bId = b->m_Uuid;
133 auto path = std::filesystem::temp_directory_path() /
"constraint_vertex_tst.kicad_pcb";
138 std::ifstream in(
path );
139 std::stringstream buf;
141 std::string
text = buf.str();
143 std::regex vertexRe(
"\\(member\\s+\"" + std::string( aId.
AsString().ToUTF8() )
144 +
"\"\\s+vertex\\s+1\\s*\\)" );
145 std::regex startWithIndexRe(
"\\(member\\s+\"[^\"]+\"\\s+start\\s+[-0-9]" );
176 auto board1 = std::make_unique<BOARD>();
184 auto path = std::filesystem::temp_directory_path() /
"constraint_vertex_validation_tst.kicad_pcb";
187 std::ifstream in(
path );
188 std::stringstream buf;
190 std::string
text = buf.str();
194 [&](
const std::string& aReplacement ) -> std::unique_ptr<BOARD>
196 std::string variant = std::regex_replace(
text, std::regex(
"vertex\\s+1" ), aReplacement );
200 auto board = std::make_unique<BOARD>();
204 []( wxString,
int, wxString, wxString ) { return true; } );
210 std::unique_ptr<BOARD> board2 = parseVariant(
"vertex" );
217 BOOST_CHECK_THROW( parseVariant(
"start 4" ),
IO_ERROR );
220 BOOST_CHECK_THROW( parseVariant(
"vertex garbage" ),
IO_ERROR );
229 auto board1 = std::make_unique<BOARD>();
239 auto path = std::filesystem::temp_directory_path() /
"constraint_missing_tst.kicad_pcb";
250 bool hasValid =
false, hasDangling =
false;
254 if( m.m_item == a->
m_Uuid )
256 else if( m.m_item == danglingId )
269 auto board1 = std::make_unique<BOARD>();
281 auto path = std::filesystem::temp_directory_path() /
"constraint_append_tst.kicad_pcb";
285 auto board2 = std::make_unique<BOARD>();
289 &reader, board2.get(),
290 []( wxString,
int, wxString, wxString )
294 nullptr, 0,
false,
true );
304 BOOST_CHECK( board2->ResolveItem( member.m_item,
true ) !=
nullptr );
General utilities for PCB file IO for QA programs.
Information pertinent to a Pcbnew printed circuit board.
const CONSTRAINTS & Constraints() const
Geometric constraints (#2329) owned by this board.
A LINE_READER that reads from an open file.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
wxString AsString() const
A geometric constraint between board items (issue #2329).
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
std::optional< double > GetValue() const
bool IsDriving() const
A driving constraint forces its value; a reference (non-driving) one only measures it.
void AddMember(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor=CONSTRAINT_ANCHOR::WHOLE, int aIndex=-1)
void SetValue(std::optional< double > aValue)
void SetDriving(bool aDriving)
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Test utilities for timestamps.
PCB_SHAPE * addSegment(BOARD &aBoard, const VECTOR2I &aStart, const VECTOR2I &aEnd)
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
void DumpBoardToFile(BOARD &board, const std::filesystem::path &aFilename)
Utility function to simply write a Board out to a file.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
@ WHOLE
The item as a whole (a segment as a line, a circle).
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
PCB_CONSTRAINT_TYPE
The geometric relationship a PCB_CONSTRAINT enforces between its members.
@ COINCIDENT
Two points are made to coincide.
@ HORIZONTAL
A segment (or two points) is horizontal.
@ FIXED_LENGTH
A segment has a driving length value.
@ PARALLEL
Two segments are parallel.
Pcbnew s-expression file format parser definition.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(RoundTrip)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()