Files
KDDockWidgets/tests/tst_viewguard.cpp
Sergio Martins bcd639599a Port tst_viewguard.cpp to doctest
doctest will be the unit-test framework for new tests, since we'll
have a lot of non-Qt code.
2022-04-26 23:35:25 +01:00

41 lines
963 B
C++

/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Waqar Ahmed <waqar.ahmed@kdab.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "ViewGuard.h"
#include "qtwidgets/views/ViewWrapper_qtwidgets.h"
#include <doctest/doctest.h>
using namespace KDDockWidgets;
TEST_CASE("ViewGuard test")
{
ViewGuard g(nullptr);
CHECK(g.isNull());
{
Views::ViewWrapper_qtwidgets wv(static_cast<QWidget *>(nullptr));
g = &wv;
CHECK(!g.isNull());
}
CHECK(g.isNull());
// Test when ViewGuard is destroyed before view
// May not crash without ASAN
Views::ViewWrapper_qtwidgets wv(static_cast<QWidget *>(nullptr));
{
ViewGuard gg(&wv);
CHECK(!gg.isNull());
}
}