Some more tests for properties inside Edges, Regions

This commit is contained in:
Matthias Koefferlein 2025-01-29 02:42:16 +01:00
parent 4fda872048
commit a282a5d665
3 changed files with 74 additions and 1 deletions

View File

@ -427,7 +427,11 @@ static void insert_st (db::Region *r, const db::Shapes &a, const Trans &t)
for (db::Shapes::shape_iterator p = a.begin (db::ShapeIterator::Polygons | db::ShapeIterator::Boxes | db::ShapeIterator::Paths); !p.at_end (); ++p) {
db::Polygon poly;
p->polygon (poly);
r->insert (poly.transformed (t));
if (p->prop_id () != 0) {
r->insert (db::PolygonWithProperties (poly.transformed (t), p->prop_id ()));
} else {
r->insert (poly.transformed (t));
}
}
}

View File

@ -955,6 +955,69 @@ class DBEdges_TestClass < TestBase
end
# properties
def test_props
r = RBA::Edges::new([ RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
r = RBA::Edges::new
r.insert([ RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
r = RBA::Edges::new(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
r = RBA::Edges::new
r.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
r = RBA::Edges::new([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
r.insert([ RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }) ])
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
r.insert(RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new(RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
r.insert(RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
r.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
r.insert(RBA::Region::new(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" })))
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
s = RBA::Shapes::new
s.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
r.insert(s)
assert_equal(r.to_s, "(0,0;0,200){1=>one};(0,200;100,200){1=>one};(100,200;100,0){1=>one};(100,0;0,0){1=>one}")
r = RBA::Edges::new
s = RBA::Shapes::new
s.insert(RBA::EdgeWithProperties::new(RBA::Edge::new(0, 0, 100, 100), { 1 => "one" }))
r.insert(s)
assert_equal(r.to_s, "(0,0;100,100){1=>one}")
end
end
load("test_epilogue.rb")

View File

@ -1562,6 +1562,12 @@ class DBRegion_TestClass < TestBase
r = RBA::Region::new(RBA::PathWithProperties::new(RBA::Path::new([ RBA::Point::new(0, 0), RBA::Point::new(100, 0) ], 20), { 1 => "one" }))
assert_equal(r.to_s, "(0,-10;0,10;100,10;100,-10){1=>one}")
r = RBA::Region::new
s = RBA::Shapes::new
s.insert(RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one" }))
r.insert(s)
assert_equal(r.to_s, "(0,0;0,200;100,200;100,0){1=>one}")
end
end