From 9622a2e66975d92ffb4b86b08f25e3b8f2889757 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 24 Apr 2018 19:28:45 +0200 Subject: [PATCH] WIP: added testcases for extreme polygon decomposition on GDS writing. --- src/db/unit_tests/dbGDS2Writer.cc | 42 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/db/unit_tests/dbGDS2Writer.cc b/src/db/unit_tests/dbGDS2Writer.cc index 7e714514e..7c4f37358 100644 --- a/src/db/unit_tests/dbGDS2Writer.cc +++ b/src/db/unit_tests/dbGDS2Writer.cc @@ -32,12 +32,12 @@ #include #include -void run_test (tl::TestBase *_this, const char *file, const char *file_ref) +void run_test (tl::TestBase *_this, const char *file, const char *file_ref, bool priv = false, const db::GDS2WriterOptions &opt = db::GDS2WriterOptions ()) { db::Manager m; db::Layout layout_org (&m); { - std::string fn (tl::testsrc ()); + std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); fn += "/testdata/gds/"; fn += file; tl::InputStream stream (fn); @@ -45,22 +45,13 @@ void run_test (tl::TestBase *_this, const char *file, const char *file_ref) reader.read (layout_org); } - db::Layout layout_ref (&m); - { - std::string fn (tl::testsrc ()); - fn += "/testdata/gds/"; - fn += file_ref; - tl::InputStream stream (fn); - db::Reader reader (stream); - reader.read (layout_ref); - } - std::string tmp_file = _this->tmp_file ("tmp.gds"); { tl::OutputStream stream (tmp_file); db::GDS2Writer writer; db::SaveLayoutOptions options; + options.set_options (new db::GDS2WriterOptions (opt)); writer.write (layout_org, stream, options); } @@ -71,6 +62,16 @@ void run_test (tl::TestBase *_this, const char *file, const char *file_ref) reader.read (layout_read); } + db::Layout layout_ref (&m); + { + std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); + fn += "/testdata/gds/"; + fn += file_ref; + tl::InputStream stream (fn); + db::Reader reader (stream); + reader.read (layout_ref); + } + bool equal = db::compare_layouts (layout_read, layout_ref, db::layout_diff::f_verbose, 0); if (! equal) { _this->raise (tl::sprintf ("Compare failed - see %s vs %s\n", tmp_file, file_ref)); @@ -1127,3 +1128,20 @@ TEST(117) s1.polygon (pp); EXPECT_EQ (pp == poly, true); } + +// Extreme fracturing by max. points +TEST(120) +{ + db::GDS2WriterOptions opt; + opt.max_vertex_count = 4; + run_test (_this, "t120a.oas.gz", "t120a_au.gds.gz", true, opt); + run_test (_this, "t120b.oas.gz", "t120b_au.gds.gz", true, opt); +} + +// Extreme fracturing by max. points +TEST(121) +{ + db::GDS2WriterOptions opt; + opt.max_vertex_count = 4; + run_test (_this, "t121.oas.gz", "t121_au.gds.gz", true, opt); +}