New unit tests for RDB scan with properties

This commit is contained in:
Matthias Koefferlein 2022-10-18 21:28:06 +02:00
parent 8f6603d88e
commit 8705b77172
1 changed files with 45 additions and 8 deletions

View File

@ -731,14 +731,28 @@ class RDB_TestClass < TestBase
c1.insert(RBA::CellInstArray::new(c2.cell_index, RBA::Trans::new(10, 20)))
c2.insert(RBA::CellInstArray::new(c3.cell_index, RBA::Trans::new(11, 21)))
l1 = ly.insert_layer(RBA::LayerInfo::new(1, 0))
c0.shapes(l1).insert(RBA::Box::new(0, 1, 2, 3))
c1.shapes(l1).insert(RBA::Box::new(0, 1, 20, 30))
prop_id = ly.properties_id([[ "a", 17 ]])
c0.shapes(l1).insert(RBA::Box::new(0, 1, 2, 3), prop_id)
prop_id = ly.properties_id([[ "a", 21 ]])
c1.shapes(l1).insert(RBA::Box::new(0, 1, 20, 30), prop_id)
c2.shapes(l1).insert(RBA::Box::new(0, 1, 21, 31))
c3.shapes(l1).insert(RBA::Box::new(0, 1, 22, 32))
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
cat.scan_layer(ly, l1)
assert_equal(rdb.tag_name(1), "a") # from property
assert_equal(cat.num_items, 4)
cn = []
rdb.each_cell { |c| cn << c.to_s_test }
assert_equal(cn.join(";"), "c0[];c1[];c2[];c3[]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c0[polygon: (0,0.001;0,0.003;0.002,0.003;0.002,0.001)/float: 17];c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
cat.scan_layer(ly, l1, nil, -1, false)
assert_equal(cat.num_items, 4)
cn = []
rdb.each_cell { |c| cn << c.to_s_test }
@ -756,7 +770,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -767,7 +781,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)]")
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -778,7 +792,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -789,7 +803,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[];c2[c1->r0 *1 0.01,0.02]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)]")
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -800,6 +814,17 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
cat.scan_shapes(c1.begin_shapes_rec(l1), false, false) # hierarchical scan
assert_equal(cat.num_items, 3)
cn = []
rdb.each_cell { |c| cn << c.to_s_test }
assert_equal(cn.join(";"), "c1[];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
@ -811,7 +836,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "c1[]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001),polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]")
assert_equal(cn.join(";"), "c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21,polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -823,7 +848,7 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "TOP[];c1[TOP->r0 *1 0,0];c2[c1->r0 *1 0.01,0.02];c3[c1->r0 *1 0.021,0.041]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "TOP[];c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
assert_equal(cn.join(";"), "TOP[];c1[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21];c2[polygon: (0,0.001;0,0.031;0.021,0.031;0.021,0.001)];c3[polygon: (0,0.001;0,0.032;0.022,0.032;0.022,0.001)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
@ -835,6 +860,18 @@ class RDB_TestClass < TestBase
assert_equal(cn.join(";"), "TOP[]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "TOP[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001)/float: 21,polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]")
rdb = RBA::ReportDatabase.new("neu")
cat = rdb.create_category("l1")
r = RBA::Region::new(c1.begin_shapes_rec(l1))
cat.scan_collection(rdb.create_cell("TOP"), RBA::CplxTrans::new(0.001), r, true, false) # flat scan
assert_equal(cat.num_items, 3)
cn = []
rdb.each_cell { |c| cn << c.to_s_test }
assert_equal(cn.join(";"), "TOP[]")
cn = []
rdb.each_cell { |c| cn << c.to_s_items }
assert_equal(cn.join(";"), "TOP[polygon: (0,0.001;0,0.03;0.02,0.03;0.02,0.001),polygon: (0.01,0.021;0.01,0.051;0.031,0.051;0.031,0.021),polygon: (0.021,0.042;0.021,0.073;0.043,0.073;0.043,0.042)]")
rdb = RBA::ReportDatabase.new("neu")