File indexing completed on 2024-11-24 04:44:08
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 #include "debugstreamtest.h" 0008 0009 #include "kolabformat/errorhandler.h" 0010 0011 #include <QTest> 0012 0013 void DebugStreamTest::testDebugstream() 0014 { 0015 Error() << "test1"; 0016 Error() << "test2" 0017 << "bla" << 3 << QMap<QString, int>(); 0018 QCOMPARE(Kolab::ErrorHandler::instance().getErrors().size(), 2); 0019 QVERIFY(Kolab::ErrorHandler::instance().getErrors().first().message.contains(QLatin1StringView("test1"))); 0020 QCOMPARE(Kolab::ErrorHandler::instance().getErrors().first().severity, Kolab::ErrorHandler::Error); 0021 QVERIFY(Kolab::ErrorHandler::instance().getErrors().last().message.contains(QLatin1StringView("bla"))); 0022 } 0023 0024 void DebugStreamTest::testDebugNotLogged() 0025 { 0026 Kolab::ErrorHandler::instance().clear(); 0027 Debug() << "test1"; 0028 QCOMPARE(Kolab::ErrorHandler::instance().getErrors().size(), 0); 0029 } 0030 0031 void DebugStreamTest::testHasError() 0032 { 0033 Debug() << "test1"; 0034 QCOMPARE(Kolab::ErrorHandler::errorOccured(), false); 0035 Warning() << "test1"; 0036 QCOMPARE(Kolab::ErrorHandler::errorOccured(), false); 0037 Error() << "test1"; 0038 QCOMPARE(Kolab::ErrorHandler::errorOccured(), true); 0039 Kolab::ErrorHandler::clearErrors(); 0040 QCOMPARE(Kolab::ErrorHandler::errorOccured(), false); 0041 } 0042 0043 QTEST_MAIN(DebugStreamTest) 0044 0045 #include "moc_debugstreamtest.cpp"