mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-08 10:45:36 +08:00
Split the giant test binaries into smaller unit tests
This is an intermediate step to have smaller unit tests. It is a trade off between having many many test executables compared to a few bigger ones. But this comes a lot closer to what QtTest is meant to be used.
This commit is contained in:
72
tests/blackmisc/testidentifier/testidentifier.cpp
Normal file
72
tests/blackmisc/testidentifier/testidentifier.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
//! \file
|
||||
//! \ingroup testblackmisc
|
||||
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTest>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
//! Testing object identifier
|
||||
class CTestIdentifier : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
//! Identifier tests
|
||||
void identifierBasics();
|
||||
};
|
||||
|
||||
//! Test identifiable object
|
||||
class CTestIdentifiable : public BlackMisc::CIdentifiable
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CTestIdentifiable(QObject *nameObject);
|
||||
};
|
||||
|
||||
void CTestIdentifier::identifierBasics()
|
||||
{
|
||||
CIdentifier o1;
|
||||
CIdentifier o2;
|
||||
CIdentifier o3("foobar");
|
||||
QVERIFY2(o1 == o2, "Two default identifiers shall be equal");
|
||||
QVERIFY2(o1 != o3, "Those identifiers shall be unequal");
|
||||
|
||||
// test object name change
|
||||
QObject q;
|
||||
q.setObjectName("foo");
|
||||
CTestIdentifiable oa(&q);
|
||||
QVERIFY2(oa.identifier().getName() == q.objectName(), "Names shall be equal");
|
||||
q.setObjectName("bar");
|
||||
QVERIFY2(oa.identifier().getName() == q.objectName(), "Names shall be equal");
|
||||
}
|
||||
|
||||
CTestIdentifiable::CTestIdentifiable(QObject *nameObject) : CIdentifiable(nameObject)
|
||||
{ }
|
||||
|
||||
} //namespace
|
||||
|
||||
//! main
|
||||
BLACKTEST_APPLESS_MAIN(BlackMiscTest::CTestIdentifier);
|
||||
|
||||
#include "testidentifier.moc"
|
||||
|
||||
//! \endcond
|
||||
Reference in New Issue
Block a user