22#include <google/protobuf/any.pb.h>
24#include <api/board/board_types.pb.h>
43 google::protobuf::Any container;
51 BOOST_REQUIRE_EQUAL( restored.
GetMembers().size(), 2 );
52 BOOST_CHECK( restored.
GetMembers()[0].m_item == a );
54 BOOST_CHECK( restored.
GetMembers()[1].m_item == b );
58 BOOST_CHECK_CLOSE( *restored.
GetValue(), 12.5, 1e-9 );
60 BOOST_CHECK( restored == original );
71 google::protobuf::Any container;
80 BOOST_CHECK( restored == original );
98 google::protobuf::Any container;
102 BOOST_REQUIRE_MESSAGE( restored.
Deserialize( container ),
103 "type " << t <<
" failed to deserialize" );
105 "type " << t <<
" came back as "
121 google::protobuf::Any container;
125 kiapi::board::types::Constraint wire;
127 BOOST_REQUIRE_EQUAL( wire.members_size(), 2 );
128 BOOST_CHECK( wire.members( 0 ).has_index() );
129 BOOST_CHECK( !wire.members( 1 ).has_index() );
134 BOOST_REQUIRE_EQUAL( restored.
GetMembers().size(), 2 );
140 BOOST_CHECK( restored == original );
150 Constraint constraint;
151 constraint.mutable_id()->set_value(
KIID().AsStdString() );
152 constraint.set_type( ConstraintType::CT_COINCIDENT );
153 constraint.set_driving(
true );
155 ConstraintMember* m = constraint.add_members();
156 m->mutable_item()->set_value(
KIID().AsStdString() );
157 m->set_anchor( ConstraintAnchor::CA_START );
160 google::protobuf::Any container;
161 container.PackFrom( constraint );
166 BOOST_REQUIRE_EQUAL( restored.
GetMembers().size(), 1 );
178 Constraint constraint;
179 constraint.mutable_id()->set_value(
KIID().AsStdString() );
180 constraint.set_type( ConstraintType::CT_COINCIDENT );
181 constraint.set_driving(
true );
183 ConstraintMember* m = constraint.add_members();
184 m->mutable_item()->set_value(
KIID().AsStdString() );
185 m->set_anchor( ConstraintAnchor::CA_VERTEX );
187 google::protobuf::Any container;
188 container.PackFrom( constraint );
193 BOOST_REQUIRE_EQUAL( restored.
GetMembers().size(), 1 );
A geometric constraint between board items (issue #2329).
const std::vector< CONSTRAINT_MEMBER > & GetMembers() const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
std::optional< double > GetValue() const
bool IsDriving() const
A driving constraint forces its value; a reference (non-driving) one only measures it.
PCB_CONSTRAINT_TYPE GetConstraintType() const
void AddMember(const KIID &aItem, CONSTRAINT_ANCHOR aAnchor=CONSTRAINT_ANCHOR::WHOLE, int aIndex=-1)
void SetValue(std::optional< double > aValue)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetDriving(bool aDriving)
@ 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.
@ FIXED_LENGTH
A segment has a driving length value.
@ ARC_ANGLE
An arc has a driving or reference swept-angle value.
@ PARALLEL
Two segments are parallel.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(RoundTrip)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")