mirror of https://github.com/KLayout/klayout.git
Added tests
This commit is contained in:
parent
6412c534b8
commit
2a85ae8e5c
|
|
@ -163,7 +163,7 @@ LogEntryData::to_string () const
|
|||
std::string res;
|
||||
|
||||
if (m_category_name != 0) {
|
||||
if (m_category_description != 0) {
|
||||
if (m_category_description == 0) {
|
||||
res += "[" + category_name () + "] ";
|
||||
} else {
|
||||
res += "[" + category_description () + "] ";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2023 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 "dbLog.h"
|
||||
|
||||
#include "tlUnitTest.h"
|
||||
|
||||
TEST(1_Basic)
|
||||
{
|
||||
db::LogEntryData data;
|
||||
EXPECT_EQ (data.severity (), db::NoSeverity);
|
||||
EXPECT_EQ (data.message (), std::string ());
|
||||
EXPECT_EQ (data.category_description (), std::string ());
|
||||
EXPECT_EQ (data.category_name (), std::string ());
|
||||
EXPECT_EQ (data.cell_name (), std::string ());
|
||||
EXPECT_EQ (data.geometry ().to_string (), "()");
|
||||
|
||||
EXPECT_EQ (data == db::LogEntryData (), true);
|
||||
EXPECT_EQ (data != db::LogEntryData (), false);
|
||||
}
|
||||
|
||||
TEST(2_Attributes)
|
||||
{
|
||||
db::LogEntryData data;
|
||||
data.set_severity (db::Error);
|
||||
data.set_message ("Message");
|
||||
data.set_category_name ("42");
|
||||
data.set_cell_name ("cell");
|
||||
data.set_category_description ("the answer");
|
||||
data.set_geometry (db::DPolygon (db::DBox (db::DPoint (1, 2), db::DPoint (3, 4))));
|
||||
|
||||
db::LogEntryData data2 = data;
|
||||
|
||||
EXPECT_EQ (data == db::LogEntryData (), false);
|
||||
EXPECT_EQ (data != db::LogEntryData (), true);
|
||||
EXPECT_EQ (data == data2, true);
|
||||
EXPECT_EQ (data != data2, false);
|
||||
|
||||
EXPECT_EQ (data.severity (), db::Error);
|
||||
EXPECT_EQ (data.message (), std::string ("Message"));
|
||||
EXPECT_EQ (data.category_description (), std::string ("the answer"));
|
||||
EXPECT_EQ (data.category_name (), std::string ("42"));
|
||||
EXPECT_EQ (data.cell_name (), std::string ("cell"));
|
||||
EXPECT_EQ (data.geometry ().to_string (), "(1,2;1,4;3,4;3,2)");
|
||||
}
|
||||
|
||||
TEST(3_toString)
|
||||
{
|
||||
db::LogEntryData data;
|
||||
data.set_severity (db::Error);
|
||||
data.set_message ("Message");
|
||||
data.set_category_name ("42");
|
||||
data.set_cell_name ("cell");
|
||||
data.set_category_description ("the answer");
|
||||
data.set_geometry (db::DPolygon (db::DBox (db::DPoint (1, 2), db::DPoint (3, 4))));
|
||||
|
||||
EXPECT_EQ (data.to_string (), std::string ("[the answer] In cell cell: Message, shape: (1,2;1,4;3,4;3,2)"));
|
||||
|
||||
data.set_category_description (std::string ());
|
||||
|
||||
EXPECT_EQ (data.to_string (), std::string ("[42] In cell cell: Message, shape: (1,2;1,4;3,4;3,2)"));
|
||||
|
||||
data.set_category_name (std::string ());
|
||||
|
||||
EXPECT_EQ (data.to_string (), std::string ("In cell cell: Message, shape: (1,2;1,4;3,4;3,2)"));
|
||||
|
||||
data.set_geometry (db::DPolygon ());
|
||||
|
||||
EXPECT_EQ (data.to_string (), std::string ("In cell cell: Message"));
|
||||
|
||||
data.set_cell_name (std::string ());
|
||||
|
||||
EXPECT_EQ (data.to_string (), std::string ("Message"));
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ include($$PWD/../../lib_ut.pri)
|
|||
SOURCES = \
|
||||
dbCompoundOperationTests.cc \
|
||||
dbFillToolTests.cc \
|
||||
dbLogTests.cc \
|
||||
dbRecursiveInstanceIteratorTests.cc \
|
||||
dbRegionCheckUtilsTests.cc \
|
||||
dbUtilsTests.cc \
|
||||
|
|
|
|||
|
|
@ -181,6 +181,12 @@ class NetlistCompare_TestClass < TestBase
|
|||
|
||||
def test_1
|
||||
|
||||
# severity enums
|
||||
assert_equal(NetlistCompareTestLogger::Info.to_s, "Info")
|
||||
assert_equal(NetlistCompareTestLogger::Error.to_s, "Error")
|
||||
assert_equal(NetlistCompareTestLogger::Warning.to_s, "Warning")
|
||||
assert_equal(NetlistCompareTestLogger::NoSeverity.to_s, "NoSeverity")
|
||||
|
||||
nl1 = RBA::Netlist::new
|
||||
nl2 = RBA::Netlist::new
|
||||
dc = RBA::DeviceClass::new
|
||||
|
|
|
|||
Loading…
Reference in New Issue