mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 01:14:35 +02:00
Some bug fixes, updated tests
This commit is contained in:
Vendored
+40
-1
@@ -294,53 +294,90 @@ class DBEdgePairs_TestClass < TestBase
|
||||
ep4 = RBA::EdgePair::new(RBA::Edge::new(0, 0, 0, 10), RBA::Edge::new(10, 0, 10, 10))
|
||||
|
||||
r1 = RBA::EdgePairs::new([ ep1, ep2, ep3, ep4 ])
|
||||
assert_equal(r1.with_angle(0, 90, false).to_s, "") # @@@
|
||||
assert_equal(r1.with_angle(0, 90, false).to_s, "")
|
||||
|
||||
assert_equal(r1.with_distance(10, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_distance(10)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_distance(5, 20, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_distance(5, 20)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_distance(15, 20, false).to_s, "")
|
||||
assert_equal(r1.split_with_distance(15, 20)[0].to_s, "")
|
||||
assert_equal(r1.with_distance(15, 20, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_distance(15, 20)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
|
||||
assert_equal(r1.with_length(10, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length(10, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length(10, 20, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length(10, 20, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length(10, 21, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length(10, 21, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length(10, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0)")
|
||||
assert_equal(r1.split_with_length(10, false)[1].to_s, "(0,0;0,20)/(10,20;10,0)")
|
||||
assert_equal(r1.with_length_both(10, false).to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length_both(10, false)[0].to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length_both(10, 20, false).to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length_both(10, 20, false)[0].to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length_both(10, 21, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_length_both(10, 21, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_length_both(10, true).to_s, "(0,0;0,20)/(10,20;10,0)")
|
||||
assert_equal(r1.split_with_length_both(10, false)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0)")
|
||||
|
||||
assert_equal(r1.with_angle(0, false).to_s, "")
|
||||
assert_equal(r1.split_with_angle(0, false)[0].to_s, "")
|
||||
assert_equal(r1.with_abs_angle(0, false).to_s, "")
|
||||
assert_equal(r1.split_with_abs_angle(0, false)[0].to_s, "")
|
||||
assert_equal(r1.with_angle(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_angle(0, false)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_abs_angle(0, false)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_angle(90, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_abs_angle(90, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle(0, 90, false).to_s, "")
|
||||
assert_equal(r1.split_with_angle(0, 90, false)[0].to_s, "")
|
||||
assert_equal(r1.with_abs_angle(0, 90, false).to_s, "")
|
||||
assert_equal(r1.split_with_abs_angle(0, 90, false)[0].to_s, "")
|
||||
assert_equal(r1.with_angle(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_angle(0, 90, false, true, true)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_abs_angle(0, 90, false, true, true)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(0, false).to_s, "")
|
||||
assert_equal(r1.split_with_angle_both(0, false)[0].to_s, "")
|
||||
assert_equal(r1.with_abs_angle_both(0, false).to_s, "")
|
||||
assert_equal(r1.split_with_abs_angle_both(0, false)[0].to_s, "")
|
||||
assert_equal(r1.with_angle_both(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_angle_both(0, false)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_abs_angle_both(0, false)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_angle_both(90, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_abs_angle_both(90, false)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_abs_angle_both(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_angle_both(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
|
||||
assert_equal(r1.with_area(0, false).to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_area(0)[0].to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_area(150, false).to_s, "(0,0;0,10)/(10,20;10,0)")
|
||||
assert_equal(r1.split_with_area(150)[0].to_s, "(0,0;0,10)/(10,20;10,0)")
|
||||
assert_equal(r1.with_area(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0)")
|
||||
assert_equal(r1.split_with_area(0)[1].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0)")
|
||||
assert_equal(r1.with_area(150, 151, false).to_s, "(0,0;0,10)/(10,20;10,0)")
|
||||
assert_equal(r1.split_with_area(150, 151)[0].to_s, "(0,0;0,10)/(10,20;10,0)")
|
||||
assert_equal(r1.with_area(150, 150, false).to_s, "")
|
||||
assert_equal(r1.split_with_area(150, 150)[0].to_s, "")
|
||||
assert_equal(r1.with_area(150, 151, true).to_s, "(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_area(150, 151)[1].to_s, "(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
|
||||
assert_equal(r1.with_internal_angle(0, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.split_with_internal_angle(0)[0].to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_internal_angle(0, 0, false).to_s, "")
|
||||
assert_equal(r1.split_with_internal_angle(0, 0)[0].to_s, "")
|
||||
assert_equal(r1.with_internal_angle(0, true).to_s, "")
|
||||
assert_equal(r1.split_with_internal_angle(0)[1].to_s, "")
|
||||
|
||||
ep1 = RBA::EdgePair::new(RBA::Edge::new(0, 0, 0, 10), RBA::Edge::new(10, 20, 10, 0))
|
||||
ep2 = RBA::EdgePair::new(RBA::Edge::new(0, 0, 0, 10), RBA::Edge::new(20, 0, 30, 0))
|
||||
@@ -419,6 +456,8 @@ class DBEdgePairs_TestClass < TestBase
|
||||
edge_pairs.insert(RBA::EdgePair::new([200, 0, 300, 0], [200, 100, 220, 300 ]))
|
||||
|
||||
assert_equal(edge_pairs.filtered(f).to_s, "(0,0;100,0)/(0,100;0,300)")
|
||||
assert_equal(edge_pairs.split_filter(f)[0].to_s, "(0,0;100,0)/(0,100;0,300)")
|
||||
assert_equal(edge_pairs.split_filter(f)[1].to_s, "(200,0;300,0)/(200,100;220,300)")
|
||||
assert_equal(edge_pairs.to_s, "(0,0;100,0)/(0,100;0,300);(200,0;300,0)/(200,100;220,300)")
|
||||
edge_pairs.filter(f)
|
||||
assert_equal(edge_pairs.to_s, "(0,0;100,0)/(0,100;0,300)")
|
||||
|
||||
Vendored
+12
@@ -585,25 +585,35 @@ class DBEdges_TestClass < TestBase
|
||||
r.insert(RBA::Edge::new(0, 0, 100, 0))
|
||||
r.insert(RBA::Edge::new(100, 0, 100, 50))
|
||||
assert_equal(r.with_angle(0, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.split_with_angle(0)[0].to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(0, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.split_with_abs_angle(0)[0].to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(0, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.split_with_angle(0)[1].to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(0, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.split_with_abs_angle(0)[1].to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(90, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(90, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(90, true).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(90, true).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(-10, 10, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.split_with_angle(-10, 10)[0].to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(-10, 10, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(-10, 10, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.split_with_angle(-10, 10)[1].to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(-10, 10, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(80, 100, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(80, 100, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(100, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.split_with_length(100)[0].to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_length(100, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.split_with_length(100)[1].to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(50, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(50, true).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_length(100, nil, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.split_with_length(100, nil)[0].to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_length(100, 200, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.split_with_length(100, 200)[1].to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(nil, 100, false).to_s, "(100,0;100,50)")
|
||||
|
||||
r = RBA::Edges::new
|
||||
@@ -882,6 +892,8 @@ class DBEdges_TestClass < TestBase
|
||||
edges.insert(RBA::Edge::new(100, 100, 100, 200))
|
||||
|
||||
assert_equal(edges.filtered(f).to_s, "(100,0;200,100)")
|
||||
assert_equal(edges.split_filter(f)[0].to_s, "(100,0;200,100)")
|
||||
assert_equal(edges.split_filter(f)[1].to_s, "(100,100;100,200)")
|
||||
assert_equal(edges.to_s, "(100,0;200,100);(100,100;100,200)")
|
||||
edges.filter(f)
|
||||
assert_equal(edges.to_s, "(100,0;200,100)")
|
||||
|
||||
Vendored
+52
@@ -485,46 +485,68 @@ class DBRegion_TestClass < TestBase
|
||||
r.merged_semantics = false
|
||||
|
||||
assert_equal(r.with_area(20000, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_area(20000)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_area(20000, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_area(20000)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(csort(r.with_area(10000, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_area(10000, 20000, false).to_s, "")
|
||||
assert_equal(r.with_area(nil, 20001, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(csort(r.with_area(10000, 20000, true).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
|
||||
assert_equal(r.with_perimeter(600, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_perimeter(600)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_perimeter(600, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_perimeter(600)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(csort(r.with_perimeter(600, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_perimeter(600, 1000, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_perimeter(nil, 1000, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_perimeter(nil, 1000)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_perimeter(600, 1000, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_perimeter(600, 1000)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
|
||||
assert_equal(r.with_bbox_height(200, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_bbox_height(200)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_bbox_height(200, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_bbox_height(200)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(csort(r.with_bbox_height(100, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_height(100, 200, false).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(csort(r.with_bbox_height(nil, 201, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.split_with_bbox_height(nil, 201)[0].to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_height(100, 200, true).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_bbox_height(100, 200)[1].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
|
||||
assert_equal(r.with_bbox_width(400, false).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_bbox_width(400)[0].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.with_bbox_width(400, true).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_bbox_width(400)[1].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(csort(r.with_bbox_width(100, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_width(100, 400, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(csort(r.with_bbox_width(nil, 401, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.split_with_bbox_width(nil, 401)[0].to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_width(100, 400, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_bbox_width(100, 400)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
|
||||
assert_equal(csort(r.with_bbox_min(100, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.split_with_bbox_min(100)[0].to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_min(100, true).to_s, "")
|
||||
assert_equal(r.split_with_bbox_min(100)[1].to_s, "")
|
||||
assert_equal(csort(r.with_bbox_min(100, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.with_bbox_min(100, 101, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.with_bbox_min(nil, 101, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(csort(r.split_with_bbox_min(nil, 101)[0].to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_min(100, 101, true).to_s, "")
|
||||
assert_equal(r.split_with_bbox_min(100, 101)[1].to_s, "")
|
||||
|
||||
assert_equal(r.with_bbox_max(200, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_bbox_max(200)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_bbox_max(200, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_bbox_max(200)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(csort(r.with_bbox_max(200, nil, false).to_s), csort("(0,0;0,200;100,200;100,0);(0,0;0,100;400,100;400,0)"))
|
||||
assert_equal(r.with_bbox_max(200, 400, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_bbox_max(nil, 400, false).to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.split_with_bbox_max(nil, 400)[0].to_s, "(0,0;0,200;100,200;100,0)")
|
||||
assert_equal(r.with_bbox_max(200, 400, true).to_s, "(0,0;0,100;400,100;400,0)")
|
||||
assert_equal(r.split_with_bbox_max(200, 400)[1].to_s, "(0,0;0,100;400,100;400,0)")
|
||||
|
||||
end
|
||||
|
||||
@@ -840,15 +862,23 @@ class DBRegion_TestClass < TestBase
|
||||
|
||||
r1.merged_semantics = false
|
||||
assert_equal(csort(r1.rectangles.to_s), csort("(10,20;10,200;100,200;100,20);(50,70;50,270;150,270;150,70)"))
|
||||
assert_equal(csort(r1.split_rectangles[0].to_s), csort("(10,20;10,200;100,200;100,20);(50,70;50,270;150,270;150,70)"))
|
||||
assert_equal(csort(r1.non_rectangles.to_s), csort("(0,0;100,100;100,0);(0,0;0,100;50,100;50,200;100,200;100,0)"))
|
||||
assert_equal(csort(r1.split_rectangles[1].to_s), csort("(0,0;100,100;100,0);(0,0;0,100;50,100;50,200;100,200;100,0)"))
|
||||
assert_equal(csort(r1.rectilinear.to_s), csort("(10,20;10,200;100,200;100,20);(50,70;50,270;150,270;150,70);(0,0;0,100;50,100;50,200;100,200;100,0)"))
|
||||
assert_equal(csort(r1.split_rectilinear[0].to_s), csort("(10,20;10,200;100,200;100,20);(50,70;50,270;150,270;150,70);(0,0;0,100;50,100;50,200;100,200;100,0)"))
|
||||
assert_equal(r1.non_rectilinear.to_s, "(0,0;100,100;100,0)")
|
||||
assert_equal(r1.split_rectilinear[1].to_s, "(0,0;100,100;100,0)")
|
||||
|
||||
r1.merged_semantics = true
|
||||
assert_equal(r1.rectangles.to_s, "")
|
||||
assert_equal(r1.split_rectangles[0].to_s, "")
|
||||
assert_equal(r1.non_rectangles.to_s, "(0,0;0,100;10,100;10,200;50,200;50,270;150,270;150,70;100,70;100,0)")
|
||||
assert_equal(r1.split_rectangles[1].to_s, "(0,0;0,100;10,100;10,200;50,200;50,270;150,270;150,70;100,70;100,0)")
|
||||
assert_equal(r1.rectilinear.to_s, "(0,0;0,100;10,100;10,200;50,200;50,270;150,270;150,70;100,70;100,0)")
|
||||
assert_equal(r1.split_rectilinear[0].to_s, "(0,0;0,100;10,100;10,200;50,200;50,270;150,270;150,70;100,70;100,0)")
|
||||
assert_equal(r1.non_rectilinear.to_s, "")
|
||||
assert_equal(r1.split_rectilinear[1].to_s, "")
|
||||
|
||||
end
|
||||
|
||||
@@ -1188,19 +1218,25 @@ class DBRegion_TestClass < TestBase
|
||||
r.insert(RBA::Box::new(0, 10000, 2000, 12000))
|
||||
|
||||
assert_equal(r.with_bbox_width(1000, false).to_s, "(0,0;0,5000;1000,5000;1000,0)")
|
||||
assert_equal(r.split_with_bbox_width(1000)[0].to_s, "(0,0;0,5000;1000,5000;1000,0)")
|
||||
assert_equal(csort(r.with_bbox_width(1000, true).to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(csort(r.split_with_bbox_width(1000)[1].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(csort(r.with_bbox_width(1000, 2001, false).to_s), csort("(0,0;0,5000;1000,5000;1000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(r.with_bbox_width(1000, 2000, false).to_s, "(0,0;0,5000;1000,5000;1000,0)")
|
||||
assert_equal(r.with_bbox_width(1000, 2001, true).to_s, "(3000,0;3000,1000;7000,1000;7000,0)")
|
||||
|
||||
assert_equal(r.with_bbox_height(5000, false).to_s, "(0,0;0,5000;1000,5000;1000,0)")
|
||||
assert_equal(r.split_with_bbox_height(5000)[0].to_s, "(0,0;0,5000;1000,5000;1000,0)")
|
||||
assert_equal(csort(r.with_bbox_height(5000, true).to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(csort(r.split_with_bbox_height(5000)[1].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(csort(r.with_bbox_height(1000, 2001, false).to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(r.with_bbox_height(1000, 1001, false).to_s, "(3000,0;3000,1000;7000,1000;7000,0)")
|
||||
assert_equal(csort(r.with_bbox_height(1000, 1001, true).to_s), csort("(0,0;0,5000;1000,5000;1000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
|
||||
assert_equal(r.with_bbox_aspect_ratio(1.0, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.split_with_bbox_aspect_ratio(1.0)[0].to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(csort(r.with_bbox_aspect_ratio(1.0, true).to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
assert_equal(csort(r.split_with_bbox_aspect_ratio(1.0)[1].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
assert_equal(r.with_bbox_aspect_ratio(0.9, 1.0, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.with_bbox_aspect_ratio(1.0, 1.1, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.with_bbox_aspect_ratio(0.9, 0.95, false).to_s, "")
|
||||
@@ -1208,7 +1244,9 @@ class DBRegion_TestClass < TestBase
|
||||
assert_equal(r.with_bbox_aspect_ratio(1.0, 1.1, false, false, true).to_s, "")
|
||||
|
||||
assert_equal(r.with_relative_height(1.0, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.split_with_relative_height(1.0)[0].to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(csort(r.with_relative_height(1.0, true).to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
assert_equal(csort(r.split_with_relative_height(1.0)[1].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
assert_equal(r.with_relative_height(0.9, 1.0, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.with_relative_height(1.0, 1.1, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.with_relative_height(0.9, 0.95, false).to_s, "")
|
||||
@@ -1216,9 +1254,13 @@ class DBRegion_TestClass < TestBase
|
||||
assert_equal(r.with_relative_height(1.0, 1.1, false, false, true).to_s, "")
|
||||
|
||||
assert_equal(csort(r.rectangles.to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(csort(r.split_rectangles[0].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0);(0,10000;0,12000;2000,12000;2000,10000)"))
|
||||
assert_equal(r.non_rectangles.to_s, "")
|
||||
assert_equal(r.split_rectangles[1].to_s, "")
|
||||
assert_equal(r.squares.to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.split_squares[0].to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(csort(r.non_squares.to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
assert_equal(csort(r.split_squares[1].to_s), csort("(3000,0;3000,1000;7000,1000;7000,0);(0,0;0,5000;1000,5000;1000,0)"))
|
||||
|
||||
r = RBA::Region::new
|
||||
r.insert(RBA::Box::new(0, 0, 1000, 2000))
|
||||
@@ -1226,7 +1268,9 @@ class DBRegion_TestClass < TestBase
|
||||
r.insert(RBA::Box::new(0, 10000, 2000, 12000))
|
||||
|
||||
assert_equal(r.with_area_ratio(1.0, false).to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.split_with_area_ratio(1.0)[0].to_s, "(0,10000;0,12000;2000,12000;2000,10000)")
|
||||
assert_equal(r.with_area_ratio(1.0, true).to_s, "(0,0;0,2000;1000,2000;1000,1000;2000,1000;2000,0)")
|
||||
assert_equal(r.split_with_area_ratio(1.0)[1].to_s, "(0,0;0,2000;1000,2000;1000,1000;2000,1000;2000,0)")
|
||||
assert_equal(r.with_area_ratio(4.0 / 3.0, false).to_s, "(0,0;0,2000;1000,2000;1000,1000;2000,1000;2000,0)")
|
||||
assert_equal(r.with_area_ratio(1.3, 1.4, false).to_s, "(0,0;0,2000;1000,2000;1000,1000;2000,1000;2000,0)")
|
||||
assert_equal(r.with_area_ratio(1.3, 4.0 / 3.0, false, false, true).to_s, "(0,0;0,2000;1000,2000;1000,1000;2000,1000;2000,0)")
|
||||
@@ -1247,11 +1291,17 @@ class DBRegion_TestClass < TestBase
|
||||
r -= rr
|
||||
|
||||
assert_equal(r.with_holes(0, false).to_s, "")
|
||||
assert_equal(r.split_with_holes(0)[0].to_s, "")
|
||||
assert_equal(r.with_holes(0, true).to_s, "(0,0;0,200;100,200;100,0/10,10;20,10;20,20;10,20/30,30;40,30;40,40;30,40)")
|
||||
assert_equal(r.split_with_holes(0)[1].to_s, "(0,0;0,200;100,200;100,0/10,10;20,10;20,20;10,20/30,30;40,30;40,40;30,40)")
|
||||
assert_equal(rr.with_holes(0, false).to_s, "(10,10;10,20;20,20;20,10);(30,30;30,40;40,40;40,30)")
|
||||
assert_equal(rr.split_with_holes(0)[0].to_s, "(10,10;10,20;20,20;20,10);(30,30;30,40;40,40;40,30)")
|
||||
assert_equal(rr.with_holes(0, true).to_s, "")
|
||||
assert_equal(rr.split_with_holes(0)[1].to_s, "")
|
||||
assert_equal(rr.with_holes(2, false).to_s, "")
|
||||
assert_equal(rr.split_with_holes(2)[0].to_s, "")
|
||||
assert_equal(r.with_holes(1, 3, false).to_s, "(0,0;0,200;100,200;100,0/10,10;20,10;20,20;10,20/30,30;40,30;40,40;30,40)")
|
||||
assert_equal(r.split_with_holes(1, 3)[0].to_s, "(0,0;0,200;100,200;100,0/10,10;20,10;20,20;10,20/30,30;40,30;40,40;30,40)")
|
||||
assert_equal(r.with_holes(2, 3, false).to_s, "(0,0;0,200;100,200;100,0/10,10;20,10;20,20;10,20/30,30;40,30;40,40;30,40)")
|
||||
assert_equal(r.with_holes(1, 2, false).to_s, "")
|
||||
|
||||
@@ -1349,6 +1399,8 @@ class DBRegion_TestClass < TestBase
|
||||
region.insert(RBA::Box::new(200, 0, 300, 100))
|
||||
|
||||
assert_equal(region.filtered(TriangleFilter::new).to_s, "(0,0;100,100;100,0)")
|
||||
assert_equal(region.split_filter(TriangleFilter::new)[0].to_s, "(0,0;100,100;100,0)")
|
||||
assert_equal(region.split_filter(TriangleFilter::new)[1].to_s, "(200,0;200,100;300,100;300,0)")
|
||||
assert_equal(region.to_s, "(0,0;100,100;100,0);(200,0;200,100;300,100;300,0)")
|
||||
region.filter(TriangleFilter::new)
|
||||
assert_equal(region.to_s, "(0,0;100,100;100,0)")
|
||||
|
||||
Vendored
+6
@@ -179,9 +179,13 @@ class DBTexts_TestClass < TestBase
|
||||
r1 = RBA::Texts::new([ text1, text2 ])
|
||||
assert_equal(csort(r1.to_s), csort("('abc',r0 100,-200);('uvm',r0 110,210)"))
|
||||
assert_equal(r1.with_text("abc", false).to_s, "('abc',r0 100,-200)")
|
||||
assert_equal(r1.split_with_text("abc")[0].to_s, "('abc',r0 100,-200)")
|
||||
assert_equal(r1.with_text("abc", true).to_s, "('uvm',r0 110,210)")
|
||||
assert_equal(r1.split_with_text("abc")[1].to_s, "('uvm',r0 110,210)")
|
||||
assert_equal(r1.with_match("*b*", false).to_s, "('abc',r0 100,-200)")
|
||||
assert_equal(r1.split_with_match("*b*")[0].to_s, "('abc',r0 100,-200)")
|
||||
assert_equal(r1.with_match("*b*", true).to_s, "('uvm',r0 110,210)")
|
||||
assert_equal(r1.split_with_match("*b*")[1].to_s, "('uvm',r0 110,210)")
|
||||
|
||||
r1 = RBA::Texts::new(text1)
|
||||
assert_equal(r1.to_s, "('abc',r0 100,-200)")
|
||||
@@ -394,6 +398,8 @@ class DBTexts_TestClass < TestBase
|
||||
texts.insert(RBA::Text::new("00", [ RBA::Trans::R90, 0, 20 ]))
|
||||
|
||||
assert_equal(texts.filtered(f).to_s, "('tla',r0 0,0)")
|
||||
assert_equal(texts.split_filter(f)[0].to_s, "('tla',r0 0,0)")
|
||||
assert_equal(texts.split_filter(f)[1].to_s, "('long',m45 10,0);('00',r90 0,20)")
|
||||
assert_equal(texts.to_s, "('long',m45 10,0);('tla',r0 0,0);('00',r90 0,20)")
|
||||
texts.filter(f)
|
||||
assert_equal(texts.to_s, "('tla',r0 0,0)")
|
||||
|
||||
Reference in New Issue
Block a user