From cd39a469a9de29f5cb01c42f75eb8f840cc65430 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 8 May 2023 12:01:43 +0200 Subject: [PATCH] Add tests for CompactStorage They're too trivial for their own QTestLib-based approach, but we don't want them in the header, either, reducing the compile times for all users, so put them into an otherwise empty .cpp file. Change-Id: Iae7fc4d4a29a0648b91752040854288e02da7045 Reviewed-by: Qt CI Bot Reviewed-by: Thiago Macieira --- src/corelib/CMakeLists.txt | 2 +- src/corelib/tools/qfunctionaltools_impl.cpp | 47 +++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/corelib/tools/qfunctionaltools_impl.cpp diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 23d74d40b9d..01c700a782e 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -281,7 +281,7 @@ qt_internal_add_module(Core tools/qduplicatetracker_p.h tools/qflatmap_p.h tools/qfreelist.cpp tools/qfreelist_p.h - tools/qfunctionaltools_impl.h + tools/qfunctionaltools_impl.cpp tools/qfunctionaltools_impl.h tools/qhashfunctions.h tools/qiterator.h tools/qline.cpp tools/qline.h diff --git a/src/corelib/tools/qfunctionaltools_impl.cpp b/src/corelib/tools/qfunctionaltools_impl.cpp new file mode 100644 index 00000000000..28148c39a22 --- /dev/null +++ b/src/corelib/tools/qfunctionaltools_impl.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include + +// Remove this file once we have tests that implicitly test all aspects of +// CompactStorage + +QT_BEGIN_NAMESPACE + +namespace QtPrivate { + +#define FOR_EACH_CVREF(op) \ + op(&) \ + op(const &) \ + op(&&) \ + op(const &&) \ + /* end */ + +namespace _testing { + struct empty {}; + struct final final {}; + static_assert(std::is_same_v, + detail::StorageEmptyBaseClassOptimization>); + static_assert(std::is_same_v, + detail::StorageByValue>); + static_assert(std::is_same_v, + detail::StorageByValue>); +#define CHECK1(Obj, cvref) \ + static_assert(std::is_same_v cvref>().object()), \ + Obj cvref>); +#define CHECK(cvref) \ + CHECK1(empty, cvref) \ + CHECK1(final, cvref) \ + CHECK1(int, cvref) \ + /* end */ + + FOR_EACH_CVREF(CHECK) +#undef CHECK +#undef CHECK1 +} // namespace _testing + +} // namespace QtPrivate + +#undef FOR_EACH_CVREF + +QT_END_NAMESPACE