diff --git a/src/plugins/streamers/lstream/db_plugin/lstrCompressor.h b/src/plugins/streamers/lstream/db_plugin/lstrCompressor.h index 03e87b798..9e57d23a6 100644 --- a/src/plugins/streamers/lstream/db_plugin/lstrCompressor.h +++ b/src/plugins/streamers/lstream/db_plugin/lstrCompressor.h @@ -137,7 +137,7 @@ static inline db::Vector reduce_object (db::EdgePairWithProperties &ep) */ static inline db::Vector reduce_object_point (db::Point &pt) { - db::Vector d = db::Point () - pt; + db::Vector d = db::Vector (pt); pt = db::Point (); return d; } diff --git a/src/plugins/streamers/lstream/unit_tests/dbLStreamWriterTests.cc b/src/plugins/streamers/lstream/unit_tests/dbLStreamWriterTests.cc new file mode 100644 index 000000000..b0f7b65a3 --- /dev/null +++ b/src/plugins/streamers/lstream/unit_tests/dbLStreamWriterTests.cc @@ -0,0 +1,153 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 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 + +*/ + +#include "lstrReader.h" +#include "dbLayoutDiff.h" +#include "dbWriter.h" +#include "dbTestSupport.h" +#include "tlUnitTest.h" + +#include + +static void run_test (tl::TestBase *_this, const std::string &base, const char *file, const char *file_au) +{ + db::LoadLayoutOptions options; + + db::Manager m (false); + db::Layout layout (&m); + + // the reader is tested in the reader tests + { + std::string fn (base); + fn += "/lstream/"; + fn += file; + tl::InputStream stream (fn); + db::Reader reader (stream); + reader.read (layout, options); + } + + // do a full spin + + std::string tmp_file = _this->tmp_file ("tmp.lstr"); + + { + tl::OutputStream stream (tmp_file); + db::SaveLayoutOptions options; + options.set_format ("LStream"); + db::Writer writer (options); + writer.write (layout, stream); + } + + db::Layout layout_read (&m); + { + tl::InputStream file (tmp_file); + db::Reader reader (file); + reader.read (layout_read); + } + + std::string fn_au (base); + fn_au += "/lstream/"; + fn_au += file_au; + + db::compare_layouts (_this, layout_read, fn_au, db::WriteOAS); +} + +TEST(basic) +{ + run_test (_this, tl::testdata (), "basic.lstr", "basic_au.oas"); +} + +TEST(boxes) +{ + run_test (_this, tl::testdata (), "boxes.lstr", "boxes_au.oas"); +} + +TEST(cells) +{ + run_test (_this, tl::testdata (), "cells.lstr", "cells_au.oas"); +} + +TEST(cells_with_instances) +{ + run_test (_this, tl::testdata (), "cells_with_instances.lstr", "cells_with_instances_au.oas"); +} + +TEST(edge_pairs) +{ + run_test (_this, tl::testdata (), "edge_pairs.lstr", "edge_pairs_au.oas"); +} + +TEST(edges) +{ + run_test (_this, tl::testdata (), "edges.lstr", "edges_au.oas"); +} + +TEST(ghost_cells) +{ + run_test (_this, tl::testdata (), "ghost_cells.lstr", "ghost_cells_au.oas"); +} + +TEST(meta_data) +{ + run_test (_this, tl::testdata (), "meta_data.lstr", "meta_data_au.oas"); +} + +TEST(paths) +{ + run_test (_this, tl::testdata (), "paths.lstr", "paths_au.oas"); +} + +TEST(pcells) +{ + run_test (_this, tl::testdata (), "pcells.lstr", "pcells_au.oas"); +} + +TEST(points) +{ + run_test (_this, tl::testdata (), "points.lstr", "points_au.oas"); +} + +TEST(polygons) +{ + run_test (_this, tl::testdata (), "polygons.lstr", "polygons_au.oas"); +} + +TEST(properties) +{ + run_test (_this, tl::testdata (), "properties.lstr", "properties_au.oas"); +} + +TEST(simple_polygons) +{ + run_test (_this, tl::testdata (), "simple_polygons.lstr", "simple_polygons_au.oas"); +} + +TEST(texts) +{ + run_test (_this, tl::testdata (), "texts.lstr", "texts_au.oas"); +} + +TEST(variants) +{ + run_test (_this, tl::testdata (), "variants.lstr", "variants_au.oas"); +} + diff --git a/src/plugins/streamers/lstream/unit_tests/unit_tests.pro b/src/plugins/streamers/lstream/unit_tests/unit_tests.pro index 8e83c6e61..5d192c4ef 100644 --- a/src/plugins/streamers/lstream/unit_tests/unit_tests.pro +++ b/src/plugins/streamers/lstream/unit_tests/unit_tests.pro @@ -7,7 +7,8 @@ include($$PWD/../lstream.pri) include($$PWD/../../../../lib_ut.pri) SOURCES = \ - dbLStreamReaderTests.cc + dbLStreamReaderTests.cc \ + dbLStreamWriterTests.cc INCLUDEPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common $$PWD/../db_plugin/capnp DEPENDPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common diff --git a/testdata/lstream/points.lstr b/testdata/lstream/points.lstr index ffc042f41..575bd9db0 100644 Binary files a/testdata/lstream/points.lstr and b/testdata/lstream/points.lstr differ diff --git a/testdata/lstream/points_au.oas b/testdata/lstream/points_au.oas index 97b971d27..4724ea73f 100644 Binary files a/testdata/lstream/points_au.oas and b/testdata/lstream/points_au.oas differ