Audacity 3.2.0
Classes | Enumerations | Functions
VariantTest.cpp File Reference
#include <catch2/catch.hpp>
#include "Callable.h"
#include "Variant.h"
Include dependency graph for VariantTest.cpp:

Go to the source code of this file.

Classes

struct  ValueType
 
struct  Tester< Const, ref >
 Parameterize for the type of visitor return. More...
 
struct  Tester< Const, ref >::X
 
struct  Tester< Const, ref >::Y
 Structure can specialize with only a non-const member function. More...
 
struct  Tester< Const, ref >::Z
 Structure always with a const member function. More...
 
struct  Tester< Const, ref >::CopyOnly
 
struct  TestVisitor
 
struct  TestVariant
 

Enumerations

enum  Ref { lvalue , rvalue , noref }
 

Functions

 TEST_CASE ("Variant visitors returning T &")
 
 TEST_CASE ("Variant visitors returning T const &")
 
 TEST_CASE ("Variant visitors returning T &&")
 
 TEST_CASE ("Variant visitors returning T const &&")
 
 TEST_CASE ("Variant visitors returning T")
 
 TEST_CASE ("Variant visitors returning T const")
 
static void compileTest ()
 

Enumeration Type Documentation

◆ Ref

enum Ref
Enumerator
lvalue 
rvalue 
noref 

Definition at line 17 of file VariantTest.cpp.

17{ lvalue, rvalue, noref };
@ rvalue
Definition: VariantTest.cpp:17
@ lvalue
Definition: VariantTest.cpp:17
@ noref
Definition: VariantTest.cpp:17

Function Documentation

◆ compileTest()

static void compileTest ( )
static

Definition at line 215 of file VariantTest.cpp.

216{
217 // Test compilation of all 16 combinations of constness and value category
218 // of the visitor and the variant
219
220 // This is an example that fails to compile when decltype(auto) in Variant.h
221 // is replaced with auto
222 TestVariant var;
223 const TestVariant cvar;
224 TestVisitor vis;
225 const TestVisitor cvis;
226
227 static_assert(std::is_same_v<int&, decltype(Visit(vis, var))>);
228 static_assert(std::is_same_v<int&, decltype(Visit(cvis, var))>);
229 static_assert(std::is_same_v<int&, decltype(Visit(std::move(vis), var))>);
230 static_assert(std::is_same_v<int&, decltype(Visit(std::move(cvis), var))>);
231
232 static_assert(std::is_same_v<int&, decltype(Visit(vis, cvar))>);
233 static_assert(std::is_same_v<int&, decltype(Visit(cvis, cvar))>);
234 static_assert(std::is_same_v<int&, decltype(Visit(std::move(vis), cvar))>);
235 static_assert(std::is_same_v<int&, decltype(Visit(std::move(cvis), cvar))>);
236
237 static_assert(std::is_same_v<int&, decltype(Visit(vis, std::move(var)))>);
238 static_assert(std::is_same_v<int&, decltype(Visit(cvis, std::move(var)))>);
239 static_assert(std::is_same_v<int&, decltype(Visit(std::move(vis), std::move(var)))>);
240 static_assert(std::is_same_v<int&, decltype(Visit(std::move(cvis), std::move(var)))>);
241
242 static_assert(std::is_same_v<int&, decltype(Visit(vis, std::move(cvar)))>);
243 static_assert(std::is_same_v<int&, decltype(Visit(cvis, std::move(cvar)))>);
244 static_assert(std::is_same_v<int&, decltype(Visit(std::move(vis), std::move(cvar)))>);
245 static_assert(std::is_same_v<int&, decltype(Visit(std::move(cvis), std::move(cvar)))>);
246}
MENUS_API void Visit(Visitor< Traits > &visitor, AudacityProject &project)

References MenuRegistry::Visit().

Here is the call graph for this function:

◆ TEST_CASE() [1/6]

TEST_CASE ( "Variant visitors returning T &"  )

Definition at line 177 of file VariantTest.cpp.

178{
180}
Parameterize for the type of visitor return.
Definition: VariantTest.cpp:29
void DoTests()

References Tester< Const, ref >::DoTests().

Here is the call graph for this function:

◆ TEST_CASE() [2/6]

TEST_CASE ( "Variant visitors returning T &&"  )

Definition at line 187 of file VariantTest.cpp.

188{
190}

References Tester< Const, ref >::DoTests().

Here is the call graph for this function:

◆ TEST_CASE() [3/6]

TEST_CASE ( "Variant visitors returning T const &"  )

Definition at line 182 of file VariantTest.cpp.

183{
185}

References Tester< Const, ref >::DoTests().

Here is the call graph for this function:

◆ TEST_CASE() [4/6]

TEST_CASE ( "Variant visitors returning T const &&"  )

Definition at line 192 of file VariantTest.cpp.

193{
195}

References Tester< Const, ref >::DoTests().

Here is the call graph for this function:

◆ TEST_CASE() [5/6]

TEST_CASE ( "Variant visitors returning T const"  )

Definition at line 202 of file VariantTest.cpp.

203{
205}

References Tester< Const, ref >::DoTests().

Here is the call graph for this function:

◆ TEST_CASE() [6/6]

TEST_CASE ( "Variant visitors returning T"  )

Definition at line 197 of file VariantTest.cpp.

198{
200}

References Tester< Const, ref >::DoTests().

Here is the call graph for this function: