mirror of https://github.com/KLayout/klayout.git
Added unit tests for db::Texts, renamed db unit test files so debugging is possible
This commit is contained in:
parent
a9cd9ac122
commit
8b083a8330
|
|
@ -0,0 +1,175 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2020 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 "tlUnitTest.h"
|
||||
|
||||
#include "dbTexts.h"
|
||||
#include "dbTextsUtils.h"
|
||||
#include "dbEdges.h"
|
||||
#include "dbRegion.h"
|
||||
|
||||
TEST(1)
|
||||
{
|
||||
db::Texts texts;
|
||||
EXPECT_EQ (texts.empty (), true);
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "()");
|
||||
EXPECT_EQ (texts == db::Texts (), true);
|
||||
EXPECT_EQ (texts < db::Texts (), false);
|
||||
EXPECT_EQ (texts != db::Texts (), false);
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
EXPECT_EQ (texts.empty (), false);
|
||||
EXPECT_EQ (texts.size (), size_t (1));
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "(100,-200;100,-200)");
|
||||
EXPECT_EQ (texts.to_string (), "('abc',r0 100,-200)");
|
||||
|
||||
texts.clear ();
|
||||
EXPECT_EQ (texts.empty (), true);
|
||||
EXPECT_EQ (texts.size (), size_t (0));
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "()");
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
EXPECT_EQ (texts == db::Texts (), false);
|
||||
EXPECT_EQ (texts < db::Texts (), true);
|
||||
EXPECT_EQ (texts != db::Texts (), true);
|
||||
EXPECT_EQ (texts != texts, false);
|
||||
EXPECT_EQ (texts == texts, true);
|
||||
EXPECT_EQ (texts < texts, false);
|
||||
EXPECT_EQ (texts.empty (), false);
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "(110,210;110,210)");
|
||||
EXPECT_EQ (texts.to_string (), "('uvw',r0 110,210)");
|
||||
|
||||
EXPECT_EQ (texts.transformed (db::ICplxTrans (2.0, 0.0, false, db::Vector ())).to_string (), "('uvw',r0 220,420)");
|
||||
EXPECT_EQ (texts.to_string (), "('uvw',r0 110,210)");
|
||||
texts.transform (db::ICplxTrans (3));
|
||||
EXPECT_EQ (texts.empty (), false);
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "(210,-110;210,-110)");
|
||||
EXPECT_EQ (texts.to_string (), "('uvw',r270 210,-110)");
|
||||
|
||||
db::Texts texts2;
|
||||
EXPECT_EQ (texts2.empty (), true);
|
||||
EXPECT_EQ (texts2.size (), size_t (0));
|
||||
EXPECT_EQ (texts2.bbox ().to_string (), "()");
|
||||
texts2.swap (texts);
|
||||
EXPECT_EQ (texts.empty (), true);
|
||||
EXPECT_EQ (texts.size (), size_t (0));
|
||||
EXPECT_EQ (texts.bbox ().to_string (), "()");
|
||||
EXPECT_EQ (texts2.empty (), false);
|
||||
EXPECT_EQ (texts2.size (), size_t (1));
|
||||
EXPECT_EQ (texts2.bbox ().to_string (), "(210,-110;210,-110)");
|
||||
}
|
||||
|
||||
TEST(2)
|
||||
{
|
||||
db::Texts texts;
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
|
||||
EXPECT_EQ (texts.to_string (), "('abc',r0 100,-200);('uvw',r0 110,210)");
|
||||
|
||||
db::Texts ee;
|
||||
std::string s = texts.to_string ();
|
||||
tl::Extractor ex (s.c_str ());
|
||||
EXPECT_EQ (ex.try_read (ee), true);
|
||||
EXPECT_EQ (ee.to_string (), "('abc',r0 100,-200);('uvw',r0 110,210)");
|
||||
|
||||
db::Edges e;
|
||||
texts.edges (e);
|
||||
EXPECT_EQ (e.to_string (), "(100,-200;100,-200);(110,210;110,210)");
|
||||
|
||||
db::Region r;
|
||||
texts.polygons (r);
|
||||
EXPECT_EQ (r.to_string (), "(99,-201;99,-199;101,-199;101,-201);(109,209;109,211;111,211;111,209)");
|
||||
}
|
||||
|
||||
TEST(3)
|
||||
{
|
||||
db::Texts texts;
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
|
||||
db::Texts tcopy = texts;
|
||||
|
||||
db::TextStringFilter f ("abc", false);
|
||||
EXPECT_EQ (texts.filtered (f).to_string (), "('abc',r0 100,-200)");
|
||||
texts.filter (f);
|
||||
EXPECT_EQ (texts.to_string (), "('abc',r0 100,-200)");
|
||||
|
||||
texts = tcopy;
|
||||
|
||||
db::TextStringFilter fi ("abc", true);
|
||||
EXPECT_EQ (texts.filtered (fi).to_string (), "('uvw',r0 110,210)");
|
||||
texts.filter (fi);
|
||||
EXPECT_EQ (texts.to_string (), "('uvw',r0 110,210)");
|
||||
}
|
||||
|
||||
TEST(4)
|
||||
{
|
||||
db::Texts texts;
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
|
||||
db::Texts tcopy = texts;
|
||||
|
||||
db::TextPatternFilter f ("*v*", false);
|
||||
EXPECT_EQ (texts.filtered (f).to_string (), "('uvw',r0 110,210)");
|
||||
texts.filter (f);
|
||||
EXPECT_EQ (texts.to_string (), "('uvw',r0 110,210)");
|
||||
|
||||
texts = tcopy;
|
||||
|
||||
db::TextPatternFilter fi ("*v*", true);
|
||||
EXPECT_EQ (texts.filtered (fi).to_string (), "('abc',r0 100,-200)");
|
||||
texts.filter (fi);
|
||||
EXPECT_EQ (texts.to_string (), "('abc',r0 100,-200)");
|
||||
}
|
||||
|
||||
TEST(5)
|
||||
{
|
||||
db::Texts texts;
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
|
||||
db::Layout ly;
|
||||
unsigned int l1 = ly.insert_layer (db::LayerProperties (1, 0));
|
||||
db::cell_index_type top_cell = ly.add_cell ("TOP");
|
||||
|
||||
texts.insert_into_as_polygons (&ly, top_cell, l1, 1);
|
||||
|
||||
db::Region r (db::RecursiveShapeIterator (ly, ly.cell (top_cell), l1));
|
||||
EXPECT_EQ (r.to_string (), "(99,-201;99,-199;101,-199;101,-201);(109,209;109,211;111,211;111,209)");
|
||||
}
|
||||
|
||||
TEST(6)
|
||||
{
|
||||
db::Texts texts;
|
||||
texts.insert (db::Text ("abc", db::Trans (db::Vector (100, -200))));
|
||||
texts.insert (db::Text ("uvw", db::Trans (db::Vector (110, 210))));
|
||||
|
||||
db::Layout ly;
|
||||
unsigned int l1 = ly.insert_layer (db::LayerProperties (1, 0));
|
||||
db::cell_index_type top_cell = ly.add_cell ("TOP");
|
||||
|
||||
texts.insert_into (&ly, top_cell, l1);
|
||||
|
||||
db::Region r (db::RecursiveShapeIterator (ly, ly.cell (top_cell), l1));
|
||||
EXPECT_EQ (r.to_string (), "(-10,-21;9,20;50,51;91,80);(-10,-21;9,20;110,121;91,80)");
|
||||
}
|
||||
|
|
@ -7,47 +7,7 @@ TARGET = db_tests
|
|||
include($$PWD/../../lib_ut.pri)
|
||||
|
||||
SOURCES = \
|
||||
dbArray.cc \
|
||||
dbBox.cc \
|
||||
dbBoxScanner.cc \
|
||||
dbBoxTree.cc \
|
||||
dbCell.cc \
|
||||
dbCellGraphUtils.cc \
|
||||
dbCellHullGenerator.cc \
|
||||
dbCellMapping.cc \
|
||||
dbClip.cc \
|
||||
dbExpression.cc \
|
||||
dbEdge.cc \
|
||||
dbEdgePair.cc \
|
||||
dbEdgePairRelations.cc \
|
||||
dbEdgePairs.cc \
|
||||
dbEdgeProcessor.cc \
|
||||
dbEdges.cc \
|
||||
dbEdgesToContours.cc \
|
||||
dbLayer.cc \
|
||||
dbLayerMapping.cc \
|
||||
dbLayout.cc \
|
||||
dbLayoutDiff.cc \
|
||||
dbLayoutUtils.cc \
|
||||
dbLibraries.cc \
|
||||
dbMatrix.cc \
|
||||
dbObject.cc \
|
||||
dbPath.cc \
|
||||
dbPCells.cc \
|
||||
dbPoint.cc \
|
||||
dbPolygon.cc \
|
||||
dbPropertiesRepository.cc \
|
||||
dbRegion.cc \
|
||||
dbShapeArray.cc \
|
||||
dbShape.cc \
|
||||
dbShapeRepository.cc \
|
||||
dbShapes.cc \
|
||||
dbText.cc \
|
||||
dbTilingProcessor.cc \
|
||||
dbTrans.cc \
|
||||
dbVector.cc \
|
||||
dbWriterTools.cc \
|
||||
dbVariableWidthPath.cc \
|
||||
dbLoadLayoutOptionsTests.cc \
|
||||
dbSaveLayoutOptionsTests.cc \
|
||||
dbHierarchyBuilderTests.cc \
|
||||
|
|
@ -73,7 +33,48 @@ SOURCES = \
|
|||
dbLayoutQueryTests.cc \
|
||||
dbPolygonToolsTests.cc \
|
||||
dbTechnologyTests.cc \
|
||||
dbStreamLayerTests.cc
|
||||
dbStreamLayerTests.cc \
|
||||
dbVectorTests.cc \
|
||||
dbVariableWidthPathTests.cc \
|
||||
dbTransTests.cc \
|
||||
dbTilingProcessorTests.cc \
|
||||
dbTextsTests.cc \
|
||||
dbTextTests.cc \
|
||||
dbShapesTests.cc \
|
||||
dbShapeRepositoryTests.cc \
|
||||
dbShapeArrayTests.cc \
|
||||
dbShapeTests.cc \
|
||||
dbRegionTests.cc \
|
||||
dbPropertiesRepositoryTests.cc \
|
||||
dbPolygonTests.cc \
|
||||
dbPointTests.cc \
|
||||
dbPCellsTests.cc \
|
||||
dbPathTests.cc \
|
||||
dbObjectTests.cc \
|
||||
dbMatrixTests.cc \
|
||||
dbLibrariesTests.cc \
|
||||
dbLayoutUtilsTests.cc \
|
||||
dbLayoutDiffTests.cc \
|
||||
dbLayoutTests.cc \
|
||||
dbLayerMappingTests.cc \
|
||||
dbLayerTests.cc \
|
||||
dbExpressionTests.cc \
|
||||
dbEdgesToContoursTests.cc \
|
||||
dbEdgesTests.cc \
|
||||
dbEdgeProcessorTests.cc \
|
||||
dbEdgePairsTests.cc \
|
||||
dbEdgePairRelationsTests.cc \
|
||||
dbEdgePairTests.cc \
|
||||
dbEdgeTests.cc \
|
||||
dbClipTests.cc \
|
||||
dbCellMappingTests.cc \
|
||||
dbCellHullGeneratorTests.cc \
|
||||
dbCellGraphUtilsTests.cc \
|
||||
dbCellTests.cc \
|
||||
dbBoxTreeTests.cc \
|
||||
dbBoxScannerTests.cc \
|
||||
dbBoxTests.cc \
|
||||
dbArrayTests.cc
|
||||
|
||||
INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC
|
||||
DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC
|
||||
|
|
|
|||
Loading…
Reference in New Issue