From 694730746bf63106ace7e6de3213f41ab8080b86 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 17 Nov 2018 00:28:32 +0100 Subject: [PATCH] WIP: added more ruby, python tests. --- testdata/python/dbRegionTest.py | 42 +++++++++++++++++++++++++++++++++ testdata/ruby/dbRegionTest.rb | 16 +++++++++++++ 2 files changed, 58 insertions(+) diff --git a/testdata/python/dbRegionTest.py b/testdata/python/dbRegionTest.py index 0cdb1efc9..1de49db34 100644 --- a/testdata/python/dbRegionTest.py +++ b/testdata/python/dbRegionTest.py @@ -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) diff --git a/testdata/ruby/dbRegionTest.rb b/testdata/ruby/dbRegionTest.rb index 3bce9e803..493aa7c68 100644 --- a/testdata/ruby/dbRegionTest.rb +++ b/testdata/ruby/dbRegionTest.rb @@ -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)