WIP: added more ruby, python tests.

This commit is contained in:
Matthias Koefferlein 2018-11-17 00:28:32 +01:00
parent a438dfd6f0
commit 694730746b
2 changed files with 58 additions and 0 deletions

View File

@ -19,6 +19,7 @@
import pya
import unittest
import sys
import os
class DBRegionTest(unittest.TestCase):
@ -39,6 +40,47 @@ class DBRegionTest(unittest.TestCase):
r.merge()
self.assertEqual(str(r), "(0,100;0,300;50,300;50,350;250,350;250,150;200,150;200,100)")
def test_deep1(self):
ut_testsrc = os.getenv("TESTSRC")
# construction/destruction magic ...
self.assertEqual(pya.DeepShapeStore.instance_count(), 0)
dss = pya.DeepShapeStore()
dss._create()
self.assertEqual(pya.DeepShapeStore.instance_count(), 1)
dss = None
self.assertEqual(pya.DeepShapeStore.instance_count(), 0)
dss = pya.DeepShapeStore()
ly = pya.Layout()
ly.read(os.path.join(ut_testsrc, "testdata", "algo", "deep_region_l1.gds"))
l1 = ly.layer(1, 0)
r = pya.Region(ly.top_cell().begin_shapes_rec(l1), dss)
rf = pya.Region(ly.top_cell().begin_shapes_rec(l1))
self.assertEqual(r.area(), 53120000)
self.assertEqual(rf.area(), 53120000)
ly_new = pya.Layout()
tc = ly_new.add_cell("TOP")
l1 = ly_new.layer(1, 0)
l2 = ly_new.layer(2, 0)
ly_new.insert(tc, l1, r)
ly_new.insert(tc, l2, rf)
s1 = { }
s2 = { }
for cell in ly_new.each_cell():
s1[cell.name] = cell.shapes(l1).size()
s2[cell.name] = cell.shapes(l2).size()
self.assertEqual(s1, {"INV2": 1, "TOP": 0, "TRANS": 0})
self.assertEqual(s2, {"INV2": 0, "TOP": 10, "TRANS": 0})
# force destroy, so the unit tests pass on the next iteration
dss = None
self.assertEqual(pya.DeepShapeStore.instance_count(), 0)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(DBRegionTest)

View File

@ -792,6 +792,22 @@ class DBRegion_TestClass < TestBase
assert_equal(r.area, 53120000)
assert_equal(rf.area, 53120000)
ly_new = RBA::Layout::new
tc = ly_new.add_cell("TOP")
l1 = ly_new.layer(1, 0)
l2 = ly_new.layer(2, 0)
ly_new.insert(tc, l1, r)
ly_new.insert(tc, l2, rf)
s1 = { }
s2 = { }
ly_new.each_cell do |cell|
s1[cell.name] = cell.shapes(l1).size
s2[cell.name] = cell.shapes(l2).size
end
assert_equal(s1, {"INV2"=>1, "TOP"=>0, "TRANS"=>0})
assert_equal(s2, {"INV2"=>0, "TOP"=>10, "TRANS"=>0})
# force destroy, so the unit tests pass on the next iteration
dss._destroy
assert_equal(RBA::DeepShapeStore::instance_count, 0)