Refactor test archetypes implementation.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278319 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-08-11 07:04:14 +00:00
parent a60053b9ee
commit 92741e2493
8 changed files with 206 additions and 164 deletions

View File

@@ -22,6 +22,7 @@
#include "archetypes.hpp"
#include "test_convertible.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
template <class T1, class T1Arg,
bool CanCopy = true, bool CanConvert = CanCopy>
@@ -58,20 +59,20 @@ int main()
// Test non-const lvalue and rvalue types
test_sfinae<AllCtors, AllCtors&>();
test_sfinae<AllCtors, AllCtors&&>();
test_sfinae<ExplicitAllCtors, ExplicitAllCtors&, true, false>();
test_sfinae<ExplicitAllCtors, ExplicitAllCtors&&, true, false>();
test_sfinae<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>();
test_sfinae<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>();
test_sfinae<CopyOnly, CopyOnly&>();
test_sfinae<CopyOnly, CopyOnly&&>();
test_sfinae<ExplicitCopyOnly, ExplicitCopyOnly&, true, false>();
test_sfinae<ExplicitCopyOnly, ExplicitCopyOnly&&, true, false>();
test_sfinae<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>();
test_sfinae<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>();
test_sfinae<MoveOnly, MoveOnly&, false>();
test_sfinae<MoveOnly, MoveOnly&&>();
test_sfinae<ExplicitMoveOnly, ExplicitMoveOnly&, false>();
test_sfinae<ExplicitMoveOnly, ExplicitMoveOnly&&, true, false>();
test_sfinae<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>();
test_sfinae<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, true, false>();
test_sfinae<NonCopyable, NonCopyable&, false>();
test_sfinae<NonCopyable, NonCopyable&&, false>();
test_sfinae<ExplicitNonCopyable, ExplicitNonCopyable&, false>();
test_sfinae<ExplicitNonCopyable, ExplicitNonCopyable&&, false>();
test_sfinae<ExplicitTypes::NonCopyable, ExplicitTypes::NonCopyable&, false>();
test_sfinae<ExplicitTypes::NonCopyable, ExplicitTypes::NonCopyable&&, false>();
}
{
// Test converting types
@@ -79,10 +80,10 @@ int main()
test_sfinae<ConvertingType, const int&>();
test_sfinae<ConvertingType, int&&>();
test_sfinae<ConvertingType, const int&&>();
test_sfinae<ExplicitConvertingType, int&, true, false>();
test_sfinae<ExplicitConvertingType, const int&, true, false>();
test_sfinae<ExplicitConvertingType, int&&, true, false>();
test_sfinae<ExplicitConvertingType, const int&&, true, false>();
test_sfinae<ExplicitTypes::ConvertingType, int&, true, false>();
test_sfinae<ExplicitTypes::ConvertingType, const int&, true, false>();
test_sfinae<ExplicitTypes::ConvertingType, int&&, true, false>();
test_sfinae<ExplicitTypes::ConvertingType, const int&&, true, false>();
}
#if TEST_STD_VER > 11
{ // explicit constexpr test

View File

@@ -20,6 +20,7 @@
#include "archetypes.hpp"
#include "test_convertible.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
@@ -62,13 +63,13 @@ int main()
}
{
test_sfinae<AllCtors>();
test_sfinae<ExplicitAllCtors, true, false>();
test_sfinae<ExplicitTypes::AllCtors, true, false>();
test_sfinae<CopyOnly>();
test_sfinae<ExplicitCopyOnly, true, false>();
test_sfinae<ExplicitTypes::CopyOnly, true, false>();
test_sfinae<MoveOnly, false>();
test_sfinae<ExplicitMoveOnly, false>();
test_sfinae<ExplicitTypes::MoveOnly, false>();
test_sfinae<NonCopyable, false>();
test_sfinae<ExplicitNonCopyable, false>();
test_sfinae<ExplicitTypes::NonCopyable, false>();
}
#if TEST_STD_VER > 11
{

View File

@@ -20,6 +20,7 @@
#include "archetypes.hpp"
#include "test_convertible.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
template <class T1, class U1,
bool CanCopy = true, bool CanConvert = CanCopy>
@@ -79,27 +80,27 @@ int main()
test_pair_const<AllCtors, const AllCtors&>();
test_pair_const<AllCtors, const AllCtors&&>();
test_pair_const<ExplicitAllCtors, ExplicitAllCtors>(); // copy construction
test_pair_const<ExplicitAllCtors, ExplicitAllCtors&, true, false>();
test_pair_const<ExplicitAllCtors, ExplicitAllCtors&&, true, false>();
test_pair_const<ExplicitAllCtors, const ExplicitAllCtors&, true, false>();
test_pair_const<ExplicitAllCtors, const ExplicitAllCtors&&, true, false>();
test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors>(); // copy construction
test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>();
test_pair_const<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>();
test_pair_const<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&, true, false>();
test_pair_const<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&&, true, false>();
test_pair_const<MoveOnly, MoveOnly, false>(); // copy construction
test_pair_const<MoveOnly, MoveOnly&, false>();
test_pair_const<MoveOnly, MoveOnly&&, false>();
test_pair_const<ExplicitMoveOnly, ExplicitMoveOnly, false>(); // copy construction
test_pair_const<ExplicitMoveOnly, ExplicitMoveOnly&, false>();
test_pair_const<ExplicitMoveOnly, ExplicitMoveOnly&&, false>();
test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly, false>(); // copy construction
test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>();
test_pair_const<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, false>();
test_pair_const<CopyOnly, CopyOnly>();
test_pair_const<CopyOnly, CopyOnly&>();
test_pair_const<CopyOnly, CopyOnly&&>();
test_pair_const<ExplicitCopyOnly, ExplicitCopyOnly>();
test_pair_const<ExplicitCopyOnly, ExplicitCopyOnly&, true, false>();
test_pair_const<ExplicitCopyOnly, ExplicitCopyOnly&&, true, false>();
test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly>();
test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>();
test_pair_const<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>();
test_pair_const<NonCopyable, NonCopyable, false>();
test_pair_const<NonCopyable, NonCopyable&, false>();
@@ -116,23 +117,23 @@ int main()
test_pair_const<NonCopyable&&, NonCopyable&&, false>();
test_pair_const<ConvertingType&, int, false>();
test_pair_const<ExplicitConvertingType&, int, false>();
test_pair_const<ExplicitTypes::ConvertingType&, int, false>();
// Unfortunately the below conversions are allowed and create dangling
// references.
//test_pair_const<ConvertingType&&, int>();
//test_pair_const<ConvertingType const&, int>();
//test_pair_const<ConvertingType const&&, int>();
// But these are not because the converting constructor is explicit.
test_pair_const<ExplicitConvertingType&&, int, false>();
test_pair_const<ExplicitConvertingType const&, int, false>();
test_pair_const<ExplicitConvertingType const&&, int, false>();
test_pair_const<ExplicitTypes::ConvertingType&&, int, false>();
test_pair_const<ExplicitTypes::ConvertingType const&, int, false>();
test_pair_const<ExplicitTypes::ConvertingType const&&, int, false>();
}
{
test_pair_const<AllCtors, int, false>();
test_pair_const<ExplicitAllCtors, int, false>();
test_pair_const<ExplicitTypes::AllCtors, int, false>();
test_pair_const<ConvertingType, int>();
test_pair_const<ExplicitConvertingType, int, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, int, true, false>();
test_pair_const<ConvertingType, int>();
test_pair_const<ConvertingType, ConvertingType>();
@@ -140,16 +141,16 @@ int main()
test_pair_const<ConvertingType, ConvertingType&>();
test_pair_const<ConvertingType, ConvertingType&&>();
test_pair_const<ExplicitConvertingType, int, true, false>();
test_pair_const<ExplicitConvertingType, int&, true, false>();
test_pair_const<ExplicitConvertingType, const int&, true, false>();
test_pair_const<ExplicitConvertingType, int&&, true, false>();
test_pair_const<ExplicitConvertingType, const int&&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, int, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, int&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, const int&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, int&&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, const int&&, true, false>();
test_pair_const<ExplicitConvertingType, ExplicitConvertingType>();
test_pair_const<ExplicitConvertingType, ExplicitConvertingType const&, true, false>();
test_pair_const<ExplicitConvertingType, ExplicitConvertingType&, true, false>();
test_pair_const<ExplicitConvertingType, ExplicitConvertingType&&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType>();
test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType const&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&, true, false>();
test_pair_const<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&&, true, false>();
}
#if TEST_STD_VER > 11
{

View File

@@ -28,6 +28,7 @@
#include "test_macros.h"
#include "archetypes.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
int main()
{

View File

@@ -21,6 +21,7 @@
#include "archetypes.hpp"
#include "test_convertible.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
template <class T1, class U1,
bool CanCopy = true, bool CanConvert = CanCopy>
@@ -89,27 +90,27 @@ int main()
test_pair_rv<AllCtors, const AllCtors&>();
test_pair_rv<AllCtors, const AllCtors&&>();
test_pair_rv<ExplicitAllCtors, ExplicitAllCtors>();
test_pair_rv<ExplicitAllCtors, ExplicitAllCtors&, true, false>();
test_pair_rv<ExplicitAllCtors, ExplicitAllCtors&&, true, false>();
test_pair_rv<ExplicitAllCtors, const ExplicitAllCtors&, true, false>();
test_pair_rv<ExplicitAllCtors, const ExplicitAllCtors&&, true, false>();
test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors>();
test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&, true, false>();
test_pair_rv<ExplicitTypes::AllCtors, ExplicitTypes::AllCtors&&, true, false>();
test_pair_rv<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&, true, false>();
test_pair_rv<ExplicitTypes::AllCtors, const ExplicitTypes::AllCtors&&, true, false>();
test_pair_rv<MoveOnly, MoveOnly>();
test_pair_rv<MoveOnly, MoveOnly&, false>();
test_pair_rv<MoveOnly, MoveOnly&&>();
test_pair_rv<ExplicitMoveOnly, ExplicitMoveOnly>(); // copy construction
test_pair_rv<ExplicitMoveOnly, ExplicitMoveOnly&, false>();
test_pair_rv<ExplicitMoveOnly, ExplicitMoveOnly&&, true, false>();
test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly>(); // copy construction
test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&, false>();
test_pair_rv<ExplicitTypes::MoveOnly, ExplicitTypes::MoveOnly&&, true, false>();
test_pair_rv<CopyOnly, CopyOnly>();
test_pair_rv<CopyOnly, CopyOnly&>();
test_pair_rv<CopyOnly, CopyOnly&&>();
test_pair_rv<ExplicitCopyOnly, ExplicitCopyOnly>();
test_pair_rv<ExplicitCopyOnly, ExplicitCopyOnly&, true, false>();
test_pair_rv<ExplicitCopyOnly, ExplicitCopyOnly&&, true, false>();
test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly>();
test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&, true, false>();
test_pair_rv<ExplicitTypes::CopyOnly, ExplicitTypes::CopyOnly&&, true, false>();
test_pair_rv<NonCopyable, NonCopyable, false>();
test_pair_rv<NonCopyable, NonCopyable&, false>();
@@ -125,22 +126,22 @@ int main()
test_pair_rv<NonCopyable&&, NonCopyable&&>();
test_pair_rv<ConvertingType&, int, false>();
test_pair_rv<ExplicitConvertingType&, int, false>();
test_pair_rv<ExplicitTypes::ConvertingType&, int, false>();
// Unfortunately the below conversions are allowed and create dangling
// references.
//test_pair_rv<ConvertingType&&, int>();
//test_pair_rv<ConvertingType const&, int>();
//test_pair_rv<ConvertingType const&&, int>();
// But these are not because the converting constructor is explicit.
test_pair_rv<ExplicitConvertingType&&, int, false>();
test_pair_rv<ExplicitConvertingType const&, int, false>();
test_pair_rv<ExplicitConvertingType const&&, int, false>();
test_pair_rv<ExplicitTypes::ConvertingType&&, int, false>();
test_pair_rv<ExplicitTypes::ConvertingType const&, int, false>();
test_pair_rv<ExplicitTypes::ConvertingType const&&, int, false>();
}
{
test_pair_rv<AllCtors, int, false>();
test_pair_rv<ExplicitAllCtors, int, false>();
test_pair_rv<ExplicitTypes::AllCtors, int, false>();
test_pair_rv<ConvertingType, int>();
test_pair_rv<ExplicitConvertingType, int, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, int, true, false>();
test_pair_rv<ConvertingType, int>();
test_pair_rv<ConvertingType, ConvertingType>();
@@ -148,16 +149,16 @@ int main()
test_pair_rv<ConvertingType, ConvertingType&>();
test_pair_rv<ConvertingType, ConvertingType&&>();
test_pair_rv<ExplicitConvertingType, int, true, false>();
test_pair_rv<ExplicitConvertingType, int&, true, false>();
test_pair_rv<ExplicitConvertingType, const int&, true, false>();
test_pair_rv<ExplicitConvertingType, int&&, true, false>();
test_pair_rv<ExplicitConvertingType, const int&&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, int, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, int&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, const int&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, int&&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, const int&&, true, false>();
test_pair_rv<ExplicitConvertingType, ExplicitConvertingType>();
test_pair_rv<ExplicitConvertingType, ExplicitConvertingType const&, true, false>();
test_pair_rv<ExplicitConvertingType, ExplicitConvertingType&, true, false>();
test_pair_rv<ExplicitConvertingType, ExplicitConvertingType&&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType>();
test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType const&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&, true, false>();
test_pair_rv<ExplicitTypes::ConvertingType, ExplicitTypes::ConvertingType&&, true, false>();
}
#if TEST_STD_VER > 11
{ // explicit constexpr test

View File

@@ -26,6 +26,7 @@
#include <tuple>
#include "archetypes.hpp"
using namespace ImplicitTypes; // Get implicitly archetypes
namespace ConstructorTest {