Some bug fixes, added tests

This commit is contained in:
Matthias Koefferlein 2020-05-13 21:56:49 +02:00
parent 831acb2c40
commit 58ca9b8730
2 changed files with 40 additions and 4 deletions

View File

@ -404,24 +404,24 @@ Class<db::Texts> decl_Texts ("db", "Texts",
"If \"inverse\" is false, this method returns the texts matching the pattern.\n"
"If \"inverse\" is true, this method returns the texts not matching the pattern.\n"
) +
method ("interacting", (db::Edges (db::Edges::*) (const db::Region &) const) &db::Edges::selected_interacting, gsi::arg ("other"),
method ("interacting", (db::Texts (db::Texts::*) (const db::Region &) const) &db::Texts::selected_interacting, gsi::arg ("other"),
"@brief Returns the texts from this text collection which are inside or on the edge of polygons from the given region\n"
"\n"
"@return A new text collection containing the texts inside or on the edge of polygons from the region\n"
) +
method ("not_interacting", (db::Edges (db::Edges::*) (const db::Region &) const) &db::Edges::selected_not_interacting, gsi::arg ("other"),
method ("not_interacting", (db::Texts (db::Texts::*) (const db::Region &) const) &db::Texts::selected_not_interacting, gsi::arg ("other"),
"@brief Returns the texts from this text collection which are not inside or on the edge of polygons from the given region\n"
"\n"
"@return A new text collection containing the texts not inside or on the edge of polygons from the region\n"
) +
method ("select_interacting", (db::Edges &(db::Edges::*) (const db::Region &)) &db::Edges::select_interacting, gsi::arg ("other"),
method ("select_interacting", (db::Texts &(db::Texts::*) (const db::Region &)) &db::Texts::select_interacting, gsi::arg ("other"),
"@brief Selects the texts from this text collection which are inside or on the edge of polygons from the given region\n"
"\n"
"@return A text collection after the texts have been selected (self)\n"
"\n"
"In contrast to \\interacting, this method will modify self.\n"
) +
method ("select_not_interacting", (db::Edges &(db::Edges::*) (const db::Region &)) &db::Edges::select_not_interacting, gsi::arg ("other"),
method ("select_not_interacting", (db::Texts &(db::Texts::*) (const db::Region &)) &db::Texts::select_not_interacting, gsi::arg ("other"),
"@brief Selects the texts from this text collection which are not inside or on the edge of polygons from the given region\n"
"\n"
"@return A text collection after the texts have been selected (self)\n"

View File

@ -211,6 +211,8 @@ class DBTexts_TestClass < TestBase
assert_equal(RBA::Texts::new(target.cell("TOP").shapes(target_li)).to_s, "")
assert_equal(RBA::Texts::new(target.cell("C2").shapes(target_li)).to_s, "('abc',r0 100,-200)")
target = RBA::Layout::new
target_top = target.add_cell("TOP")
target_li = target.layer
r.with_text("abc", false).insert_into(target, target_top, target_li)
cells = []
@ -259,6 +261,8 @@ class DBTexts_TestClass < TestBase
assert_equal(RBA::Texts::new(target.cell("TOP").shapes(target_li)).to_s, "")
assert_equal(RBA::Texts::new(target.cell("C2").shapes(target_li)).to_s, "")
target = RBA::Layout::new
target_top = target.add_cell("TOP")
target_li = target.layer
r.insert_into_as_polygons(target, target_top, target_li, 1)
cells = []
@ -267,6 +271,38 @@ class DBTexts_TestClass < TestBase
assert_equal(RBA::Region::new(target.cell("TOP").shapes(target_li)).to_s, "")
assert_equal(RBA::Region::new(target.cell("C2").shapes(target_li)).to_s, "(99,-201;99,-199;101,-199;101,-201)")
target_li = target.layer
target.insert(target_top, target_li, r)
cells = []
target.each_cell { |c| cells << c.name }
assert_equal(cells.join(","), "TOP,C2")
assert_equal(RBA::Texts::new(target.cell("TOP").shapes(target_li)).to_s, "")
assert_equal(RBA::Region::new(target.cell("TOP").shapes(target_li)).to_s, "")
assert_equal(RBA::Texts::new(target.cell("C2").shapes(target_li)).to_s, "('abc',r0 100,-200)")
assert_equal(RBA::Region::new(target.cell("C2").shapes(target_li)).to_s, "")
end
# interact
def test_5
r = RBA::Texts::new
r.insert(RBA::Text::new("abc", RBA::Trans::new(RBA::Vector::new(100, 200))))
r.insert(RBA::Text::new("uvw", RBA::Trans::new(RBA::Vector::new(110, -210))))
g2 = RBA::Region::new
g2.insert(RBA::Box::new(0, 100, 200, 200))
assert_equal(r.interacting(g2).to_s, "('abc',r0 100,200)")
assert_equal(r.not_interacting(g2).to_s, "('uvw',r0 110,-210)")
rr = r.dup
rr.select_interacting(g2)
assert_equal(rr.to_s, "('abc',r0 100,200)")
rr = r.dup
rr.select_not_interacting(g2)
assert_equal(rr.to_s, "('uvw',r0 110,-210)")
assert_equal(r.pull_interacting(g2).to_s, "(0,100;0,200;200,200;200,100)")
end
end