mirror of https://github.com/KLayout/klayout.git
WIP: consistent naming of some predicates in Ruby with ?, unit tests for reader option bindings.
This commit is contained in:
parent
17e9e48831
commit
65cfb2d4e4
|
|
@ -415,7 +415,7 @@ gsi::ClassExt<db::LoadLayoutOptions> dxf_reader_options (
|
|||
"@args value\n"
|
||||
"\nThis property has been added in version 0.21.15.\n"
|
||||
) +
|
||||
gsi::method_ext ("dxf_render_texts_as_polygons", &get_dxf_render_texts_as_polygons,
|
||||
gsi::method_ext ("dxf_render_texts_as_polygons?|#dxf_render_texts_as_polygons", &get_dxf_render_texts_as_polygons,
|
||||
"@brief If this option is true, text objects are rendered as polygons\n"
|
||||
"\nThis property has been added in version 0.21.15.\n"
|
||||
) +
|
||||
|
|
@ -442,7 +442,7 @@ gsi::ClassExt<db::LoadLayoutOptions> dxf_reader_options (
|
|||
"@args value\n"
|
||||
"\nThis property has been added in version 0.21.15.\n"
|
||||
) +
|
||||
gsi::method_ext ("dxf_keep_other_cells", &get_dxf_keep_other_cells,
|
||||
gsi::method_ext ("dxf_keep_other_cells?|#dxf_keep_other_cells", &get_dxf_keep_other_cells,
|
||||
"@brief If this option is true, all cells are kept, not only the top cell and it's children\n"
|
||||
"\nThis property has been added in version 0.21.15.\n"
|
||||
) +
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ gsi::ClassExt<db::LoadLayoutOptions> gds2_reader_options (
|
|||
"For strict compatibility with the standard, this property should be set to false. The default is true.\n"
|
||||
"\nThis property has been added in version 0.18.\n"
|
||||
) +
|
||||
gsi::method_ext ("gds2_allow_multi_xy_records", &get_gds2_allow_multi_xy_records,
|
||||
gsi::method_ext ("gds2_allow_multi_xy_records?|#gds2_allow_multi_xy_records", &get_gds2_allow_multi_xy_records,
|
||||
"@brief Gets a value specifying whether to allow big polygons with multiple XY records.\n"
|
||||
"See \\gds2_allow_multi_xy_records= method for a description of this property."
|
||||
"\nThis property has been added in version 0.18.\n"
|
||||
|
|
@ -179,7 +179,7 @@ gsi::ClassExt<db::LoadLayoutOptions> gds2_reader_options (
|
|||
"For strict compatibility with the standard, this property should be set to false. The default is true.\n"
|
||||
"\nThis property has been added in version 0.18.\n"
|
||||
) +
|
||||
gsi::method_ext ("gds2_allow_big_records", &get_gds2_allow_big_records,
|
||||
gsi::method_ext ("gds2_allow_big_records?|#gds2_allow_big_records", &get_gds2_allow_big_records,
|
||||
"@brief Gets a value specifying whether to allow big records with a length of 32768 to 65535 bytes.\n"
|
||||
"See \\gds2_allow_big_records= method for a description of this property."
|
||||
"\nThis property has been added in version 0.18.\n"
|
||||
|
|
|
|||
|
|
@ -1363,6 +1363,7 @@ LayerPropertiesList::append (const LayerPropertiesList &other)
|
|||
std::map <unsigned int, unsigned int> index_map;
|
||||
dp.merge (dither_pattern (), index_map);
|
||||
|
||||
// remap the dither pattern index
|
||||
for (lay::LayerPropertiesIterator l = begin_recursive (); l != end_recursive (); ++l) {
|
||||
int dpi = l->dither_pattern (false /*local*/);
|
||||
std::map <unsigned int, unsigned int>::iterator m = index_map.find ((unsigned int) dpi);
|
||||
|
|
@ -1380,7 +1381,7 @@ LayerPropertiesList::append (const LayerPropertiesList &other)
|
|||
std::map <unsigned int, unsigned int> index_map;
|
||||
ls.merge (line_styles (), index_map);
|
||||
|
||||
// remap the dither pattern index
|
||||
// remap the line style index
|
||||
for (lay::LayerPropertiesIterator l = begin_recursive (); l != end_recursive (); ++l) {
|
||||
int lsi = l->line_style (false /*local*/);
|
||||
std::map <unsigned int, unsigned int>::iterator m = index_map.find ((unsigned int) lsi);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ void run_pythontest (tl::TestBase *_this, const std::string &fn)
|
|||
|
||||
PYTHONTEST (dbLayoutTest, "dbLayoutTest.py")
|
||||
PYTHONTEST (dbRegionTest, "dbRegionTest.py")
|
||||
PYTHONTEST (dbReaders, "dbReaders.py")
|
||||
PYTHONTEST (dbPCellsTest, "dbPCells.py")
|
||||
PYTHONTEST (dbPolygonTest, "dbPolygonTest.py")
|
||||
PYTHONTEST (dbTransTest, "dbTransTest.py")
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ RUBYTEST (dbPCells, "dbPCells.rb")
|
|||
RUBYTEST (dbPointTest, "dbPointTest.rb")
|
||||
RUBYTEST (dbPolygonTest, "dbPolygonTest.rb")
|
||||
RUBYTEST (dbRegionTest, "dbRegionTest.rb")
|
||||
RUBYTEST (dbReaders, "dbReaders.rb")
|
||||
RUBYTEST (dbShapesTest, "dbShapesTest.rb")
|
||||
RUBYTEST (dbSimplePolygonTest, "dbSimplePolygonTest.rb")
|
||||
RUBYTEST (dbTextTest, "dbTextTest.rb")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2018 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import pya
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
class DBReadersTests(unittest.TestCase):
|
||||
|
||||
# Common Options
|
||||
def test_common_options(self):
|
||||
|
||||
opt = pya.LoadLayoutOptions()
|
||||
lm = pya.LayerMap()
|
||||
lm.map(pya.LayerInfo(1, 0), 2, pya.LayerInfo(42, 17))
|
||||
opt.set_layer_map(lm, True)
|
||||
|
||||
self.assertEqual(opt.layer_map().to_string(), "1/0 : 42/17\n")
|
||||
self.assertEqual(opt.create_other_layers, True)
|
||||
|
||||
opt.create_other_layers = False
|
||||
self.assertEqual(opt.create_other_layers, False)
|
||||
|
||||
opt.select_all_layers()
|
||||
self.assertEqual(opt.layer_map().to_string(), "")
|
||||
self.assertEqual(opt.create_other_layers, True)
|
||||
|
||||
opt.text_enabled = True
|
||||
self.assertEqual(opt.text_enabled, True)
|
||||
opt.text_enabled = False
|
||||
self.assertEqual(opt.text_enabled, False)
|
||||
|
||||
opt.properties_enabled = True
|
||||
self.assertEqual(opt.properties_enabled, True)
|
||||
opt.properties_enabled = False
|
||||
self.assertEqual(opt.properties_enabled, False)
|
||||
|
||||
# GDS2 Options
|
||||
def test_gds2_options(self):
|
||||
|
||||
opt = pya.LoadLayoutOptions()
|
||||
lm = pya.LayerMap()
|
||||
lm.map(pya.LayerInfo(1, 0), 2, pya.LayerInfo(42, 17))
|
||||
opt.set_layer_map(lm, True)
|
||||
|
||||
opt.gds2_allow_multi_xy_records = True
|
||||
self.assertEqual(opt.gds2_allow_multi_xy_records, True)
|
||||
opt.gds2_allow_multi_xy_records = False
|
||||
self.assertEqual(opt.gds2_allow_multi_xy_records, False)
|
||||
|
||||
opt.gds2_allow_big_records = True
|
||||
self.assertEqual(opt.gds2_allow_big_records, True)
|
||||
opt.gds2_allow_big_records = False
|
||||
self.assertEqual(opt.gds2_allow_big_records, False)
|
||||
|
||||
opt.gds2_box_mode = 1
|
||||
self.assertEqual(opt.gds2_box_mode, 1)
|
||||
opt.gds2_box_mode = 2
|
||||
self.assertEqual(opt.gds2_box_mode, 2)
|
||||
|
||||
# OASIS Options
|
||||
def test_oasis_options(self):
|
||||
|
||||
# none yet.
|
||||
pass
|
||||
|
||||
# DXF Options
|
||||
def test_dxf_options(self):
|
||||
|
||||
opt = pya.LoadLayoutOptions()
|
||||
lm = pya.LayerMap()
|
||||
lm.map(pya.LayerInfo(1, 0), 2, pya.LayerInfo(42, 17))
|
||||
opt.dxf_set_layer_map(lm, True)
|
||||
|
||||
self.assertEqual(opt.dxf_layer_map().to_string(), "1/0 : 42/17\n")
|
||||
self.assertEqual(opt.dxf_create_other_layers, True)
|
||||
|
||||
opt.dxf_create_other_layers = False
|
||||
self.assertEqual(opt.dxf_create_other_layers, False)
|
||||
|
||||
opt.dxf_select_all_layers()
|
||||
self.assertEqual(opt.dxf_layer_map().to_string(), "")
|
||||
self.assertEqual(opt.dxf_create_other_layers, True)
|
||||
|
||||
opt.dxf_dbu = 0.5
|
||||
self.assertEqual(opt.dxf_dbu, 0.5)
|
||||
|
||||
opt.dxf_unit = 42
|
||||
self.assertEqual(opt.dxf_unit, 42)
|
||||
|
||||
opt.dxf_text_scaling = 0.25
|
||||
self.assertEqual(opt.dxf_text_scaling, 0.25)
|
||||
|
||||
opt.dxf_circle_points = 142
|
||||
self.assertEqual(opt.dxf_circle_points, 142)
|
||||
|
||||
opt.dxf_circle_accuracy = 1.5
|
||||
self.assertEqual(opt.dxf_circle_accuracy, 1.5)
|
||||
|
||||
opt.dxf_contour_accuracy = 0.75
|
||||
self.assertEqual(opt.dxf_contour_accuracy, 0.75)
|
||||
|
||||
opt.dxf_render_texts_as_polygons = True
|
||||
self.assertEqual(opt.dxf_render_texts_as_polygons, True)
|
||||
opt.dxf_render_texts_as_polygons = False
|
||||
self.assertEqual(opt.dxf_render_texts_as_polygons, False)
|
||||
|
||||
opt.dxf_keep_layer_names = True
|
||||
self.assertEqual(opt.dxf_keep_layer_names, True)
|
||||
opt.dxf_keep_layer_names = False
|
||||
self.assertEqual(opt.dxf_keep_layer_names, False)
|
||||
|
||||
opt.dxf_keep_other_cells = True
|
||||
self.assertEqual(opt.dxf_keep_other_cells, True)
|
||||
opt.dxf_keep_other_cells = False
|
||||
self.assertEqual(opt.dxf_keep_other_cells, False)
|
||||
|
||||
opt.dxf_polyline_mode = 2
|
||||
self.assertEqual(opt.dxf_polyline_mode, 2)
|
||||
opt.dxf_polyline_mode = 4
|
||||
self.assertEqual(opt.dxf_polyline_mode, 4)
|
||||
|
||||
# CIF Options
|
||||
def test_cif_options(self):
|
||||
|
||||
opt = pya.LoadLayoutOptions()
|
||||
lm = pya.LayerMap()
|
||||
lm.map(pya.LayerInfo(1, 0), 2, pya.LayerInfo(42, 17))
|
||||
opt.cif_set_layer_map(lm, True)
|
||||
|
||||
self.assertEqual(opt.cif_layer_map().to_string(), "1/0 : 42/17\n")
|
||||
self.assertEqual(opt.cif_create_other_layers, True)
|
||||
|
||||
opt.cif_create_other_layers = False
|
||||
self.assertEqual(opt.cif_create_other_layers, False)
|
||||
|
||||
opt.cif_select_all_layers()
|
||||
self.assertEqual(opt.cif_layer_map().to_string(), "")
|
||||
self.assertEqual(opt.cif_create_other_layers, True)
|
||||
|
||||
opt.cif_keep_layer_names = True
|
||||
self.assertEqual(opt.cif_keep_layer_names, True)
|
||||
opt.cif_keep_layer_names = False
|
||||
self.assertEqual(opt.cif_keep_layer_names, False)
|
||||
|
||||
opt.cif_wire_mode = 2
|
||||
self.assertEqual(opt.cif_wire_mode, 2)
|
||||
opt.cif_wire_mode = 4
|
||||
self.assertEqual(opt.cif_wire_mode, 4)
|
||||
|
||||
opt.cif_dbu = 0.5
|
||||
self.assertEqual(opt.cif_dbu, 0.5)
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(DBReadersTests)
|
||||
|
||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
# KLayout Layout Viewer
|
||||
# Copyright (C) 2006-2018 Matthias Koefferlein
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
if !$:.member?(File::dirname($0))
|
||||
$:.push(File::dirname($0))
|
||||
end
|
||||
|
||||
load("test_prologue.rb")
|
||||
|
||||
class DBReaders_TestClass < TestBase
|
||||
|
||||
# Common Options
|
||||
def test_common_options
|
||||
|
||||
opt = RBA::LoadLayoutOptions::new
|
||||
lm = RBA::LayerMap::new
|
||||
lm.map(RBA::LayerInfo::new(1, 0), 2, RBA::LayerInfo::new(42, 17))
|
||||
opt.set_layer_map(lm, true)
|
||||
|
||||
assert_equal(opt.layer_map.to_string, "1/0 : 42/17\n")
|
||||
assert_equal(opt.create_other_layers?, true)
|
||||
|
||||
opt.create_other_layers = false
|
||||
assert_equal(opt.create_other_layers?, false)
|
||||
|
||||
opt.select_all_layers
|
||||
assert_equal(opt.layer_map.to_string, "")
|
||||
assert_equal(opt.create_other_layers?, true)
|
||||
|
||||
opt.text_enabled = true
|
||||
assert_equal(opt.text_enabled?, true)
|
||||
opt.text_enabled = false
|
||||
assert_equal(opt.text_enabled?, false)
|
||||
|
||||
opt.properties_enabled = true
|
||||
assert_equal(opt.properties_enabled?, true)
|
||||
opt.properties_enabled = false
|
||||
assert_equal(opt.properties_enabled?, false)
|
||||
|
||||
end
|
||||
|
||||
# GDS2 Options
|
||||
def test_gds2_options
|
||||
|
||||
opt = RBA::LoadLayoutOptions::new
|
||||
lm = RBA::LayerMap::new
|
||||
lm.map(RBA::LayerInfo::new(1, 0), 2, RBA::LayerInfo::new(42, 17))
|
||||
opt.set_layer_map(lm, true)
|
||||
|
||||
opt.gds2_allow_multi_xy_records = true
|
||||
assert_equal(opt.gds2_allow_multi_xy_records?, true)
|
||||
opt.gds2_allow_multi_xy_records = false
|
||||
assert_equal(opt.gds2_allow_multi_xy_records?, false)
|
||||
|
||||
opt.gds2_allow_big_records = true
|
||||
assert_equal(opt.gds2_allow_big_records?, true)
|
||||
opt.gds2_allow_big_records = false
|
||||
assert_equal(opt.gds2_allow_big_records?, false)
|
||||
|
||||
opt.gds2_box_mode = 1
|
||||
assert_equal(opt.gds2_box_mode, 1)
|
||||
opt.gds2_box_mode = 2
|
||||
assert_equal(opt.gds2_box_mode, 2)
|
||||
|
||||
end
|
||||
|
||||
# OASIS Options
|
||||
def test_oasis_options
|
||||
|
||||
# none yet.
|
||||
|
||||
end
|
||||
|
||||
# DXF Options
|
||||
def test_dxf_options
|
||||
|
||||
opt = RBA::LoadLayoutOptions::new
|
||||
lm = RBA::LayerMap::new
|
||||
lm.map(RBA::LayerInfo::new(1, 0), 2, RBA::LayerInfo::new(42, 17))
|
||||
opt.dxf_set_layer_map(lm, true)
|
||||
|
||||
assert_equal(opt.dxf_layer_map.to_string, "1/0 : 42/17\n")
|
||||
assert_equal(opt.dxf_create_other_layers?, true)
|
||||
|
||||
opt.dxf_create_other_layers = false
|
||||
assert_equal(opt.dxf_create_other_layers?, false)
|
||||
|
||||
opt.dxf_select_all_layers
|
||||
assert_equal(opt.dxf_layer_map.to_string, "")
|
||||
assert_equal(opt.dxf_create_other_layers?, true)
|
||||
|
||||
opt.dxf_dbu = 0.5
|
||||
assert_equal(opt.dxf_dbu, 0.5)
|
||||
|
||||
opt.dxf_unit = 42
|
||||
assert_equal(opt.dxf_unit, 42)
|
||||
|
||||
opt.dxf_text_scaling = 0.25
|
||||
assert_equal(opt.dxf_text_scaling, 0.25)
|
||||
|
||||
opt.dxf_circle_points = 142
|
||||
assert_equal(opt.dxf_circle_points, 142)
|
||||
|
||||
opt.dxf_circle_accuracy = 1.5
|
||||
assert_equal(opt.dxf_circle_accuracy, 1.5)
|
||||
|
||||
opt.dxf_contour_accuracy = 0.75
|
||||
assert_equal(opt.dxf_contour_accuracy, 0.75)
|
||||
|
||||
opt.dxf_render_texts_as_polygons = true
|
||||
assert_equal(opt.dxf_render_texts_as_polygons?, true)
|
||||
opt.dxf_render_texts_as_polygons = false
|
||||
assert_equal(opt.dxf_render_texts_as_polygons?, false)
|
||||
|
||||
opt.dxf_keep_layer_names = true
|
||||
assert_equal(opt.dxf_keep_layer_names?, true)
|
||||
opt.dxf_keep_layer_names = false
|
||||
assert_equal(opt.dxf_keep_layer_names?, false)
|
||||
|
||||
opt.dxf_keep_other_cells = true
|
||||
assert_equal(opt.dxf_keep_other_cells?, true)
|
||||
opt.dxf_keep_other_cells = false
|
||||
assert_equal(opt.dxf_keep_other_cells?, false)
|
||||
|
||||
opt.dxf_polyline_mode = 2
|
||||
assert_equal(opt.dxf_polyline_mode, 2)
|
||||
opt.dxf_polyline_mode = 4
|
||||
assert_equal(opt.dxf_polyline_mode, 4)
|
||||
|
||||
end
|
||||
|
||||
# CIF Options
|
||||
def test_cif_options
|
||||
|
||||
opt = RBA::LoadLayoutOptions::new
|
||||
lm = RBA::LayerMap::new
|
||||
lm.map(RBA::LayerInfo::new(1, 0), 2, RBA::LayerInfo::new(42, 17))
|
||||
opt.cif_set_layer_map(lm, true)
|
||||
|
||||
assert_equal(opt.cif_layer_map.to_string, "1/0 : 42/17\n")
|
||||
assert_equal(opt.cif_create_other_layers?, true)
|
||||
|
||||
opt.cif_create_other_layers = false
|
||||
assert_equal(opt.cif_create_other_layers?, false)
|
||||
|
||||
opt.cif_select_all_layers
|
||||
assert_equal(opt.cif_layer_map.to_string, "")
|
||||
assert_equal(opt.cif_create_other_layers?, true)
|
||||
|
||||
opt.cif_keep_layer_names = true
|
||||
assert_equal(opt.cif_keep_layer_names?, true)
|
||||
opt.cif_keep_layer_names = false
|
||||
assert_equal(opt.cif_keep_layer_names?, false)
|
||||
|
||||
opt.cif_wire_mode = 2
|
||||
assert_equal(opt.cif_wire_mode, 2)
|
||||
opt.cif_wire_mode = 4
|
||||
assert_equal(opt.cif_wire_mode, 4)
|
||||
|
||||
opt.cif_dbu = 0.5
|
||||
assert_equal(opt.cif_dbu, 0.5)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue