Audacity 3.2.0
TypeEnumeratorTest.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 TypeEnumerator.cpp
7 @brief compilation-only tests as examples of use of TypeEnumerator
8
9 Paul Licameli
10
11**********************************************************************/
12#include <catch2/catch.hpp>
13#include "TypeEnumerator.h"
14
15using namespace TypeEnumerator;
16using namespace TypeList;
17
20
21ENUMERATE_TYPE(Tag1, void)
22ENUMERATE_TYPE(Tag2, char)
23
24TEST_CASE("Using different tags")
25{
26 struct Here1 : Tag1{};
27 struct Here2 : Tag2{};
28 static_assert(std::is_same_v<List<void>,
30 static_assert(std::is_same_v<List<char>,
32}
33
34ENUMERATE_TYPE(Tag1, const volatile int&)
35ENUMERATE_TYPE(Tag2, long)
36
37TEST_CASE("Dependency on location")
38{
39 struct Here1 : Tag1{};
40 struct Here2 : Tag2{};
41 static_assert(std::is_same_v<List<void, const volatile int&>,
43 static_assert(std::is_same_v<List<char, long>,
45}
46
47ENUMERATE_TYPE(Tag1, const volatile int&)
48ENUMERATE_TYPE(Tag2, long)
49
50TEST_CASE("Distinct types, only")
51{
52 struct Here1 : Tag1{};
53 struct Here2 : Tag2{};
54 static_assert(std::is_same_v<List<void, const volatile int&>,
56 static_assert(std::is_same_v<List<char, long>,
58}
Make a list of all distinct types so far mentioned in calls of a certain macro.
#define BEGIN_TYPE_ENUMERATION(Tag)
#define ENUMERATE_TYPE(Tag, T)
This macro must occur at file scope, not within any other namespace.
TEST_CASE("Using different tags")
typename Accumulate< 0 >::type type
Utilities for compile-time type manipulation. Some terminology as in Lisp.
Definition: TypeList.h:22