based

Opinionated utility library
git clone git://git.dimitrijedobrota.com/based.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

standard_traits_test.cpp (9205B)


0 // #define CATCH_CONFIG_RUNTIME_STATIC_REQUIRE 1 2 #include <catch2/catch_test_macros.hpp> 3 4 #include "based/type_traits.hpp" 5 6 // NOLINTBEGIN(*array*) 7 8 using based::SameAs; 9 10 TEST_CASE("remove_const", "[type_traits/remove_const]") 11 { 12 // clang-format off 13 STATIC_REQUIRE(SameAs<based::remove_const_t<int>, int>); 14 STATIC_REQUIRE(SameAs<based::remove_const_t<int&>, int&>); 15 STATIC_REQUIRE(SameAs<based::remove_const_t<int&&>, int&&>); 16 STATIC_REQUIRE(SameAs<based::remove_const_t<int[2]>, int[2]>); 17 STATIC_REQUIRE(SameAs<based::remove_const_t<int(&)[2]>, int(&)[2]>); 18 STATIC_REQUIRE(SameAs<based::remove_const_t<int(&&)[2]>, int(&&)[2]>); 19 STATIC_REQUIRE(SameAs<based::remove_const_t<const int>, int>); 20 STATIC_REQUIRE(SameAs<based::remove_const_t<const int&>, const int&>); 21 STATIC_REQUIRE(SameAs<based::remove_const_t<const int[2]>, int[2]>); 22 STATIC_REQUIRE(SameAs<based::remove_const_t<const int(&)[2]>, const int(&)[2]>); 23 STATIC_REQUIRE(SameAs<based::remove_const_t<int(int)>, int(int)>); 24 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int>, volatile int>); 25 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int&>, volatile int&>); 26 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int&&>, volatile int&&>); 27 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int[2]>, volatile int[2]>); 28 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int(&)[2]>, volatile int(&)[2]>); 29 STATIC_REQUIRE(SameAs<based::remove_const_t<volatile int(&&)[2]>, volatile int(&&)[2]>); 30 STATIC_REQUIRE(SameAs<based::remove_const_t<const volatile int>, volatile int>); 31 STATIC_REQUIRE(SameAs<based::remove_const_t<const volatile int&>, volatile const int&>); 32 STATIC_REQUIRE(SameAs<based::remove_const_t<const volatile int[2]>, volatile int[2]>); 33 STATIC_REQUIRE(SameAs<based::remove_const_t<const volatile int(&)[2]>, volatile const int(&)[2]>); 34 // clang-format on 35 } 36 37 TEST_CASE("remove_volatile", "[type_traits/remove_volatile]") 38 { 39 // clang-format off 40 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int>, int>); 41 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int&>, int&>); 42 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int&&>, int&&>); 43 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int[2]>, int[2]>); 44 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int(&)[2]>, int(&)[2]>); 45 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int(&&)[2]>, int(&&)[2]>); 46 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const int>, const int>); 47 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const int&>, const int&>); 48 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const int[2]>, const int[2]>); 49 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const int(&)[2]>, const int(&)[2]>); 50 STATIC_REQUIRE(SameAs<based::remove_volatile_t<int(int)>, int(int)>); 51 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int>, int>); 52 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int&>, volatile int&>); 53 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int&&>, volatile int&&>); 54 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int[2]>, int[2]>); 55 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int(&)[2]>, volatile int(&)[2]>); 56 STATIC_REQUIRE(SameAs<based::remove_volatile_t<volatile int(&&)[2]>, volatile int(&&)[2]>); 57 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const volatile int>, const int>); 58 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const volatile int&>, volatile const int&>); 59 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const volatile int[2]>, const int[2]>); 60 STATIC_REQUIRE(SameAs<based::remove_volatile_t<const volatile int(&)[2]>, volatile const int(&)[2]>); 61 // clang-format on 62 } 63 64 TEST_CASE("remove_cv", "[type_traits/remove_cv]") 65 { 66 // clang-format off 67 STATIC_REQUIRE(SameAs<based::remove_cv_t<int>, int>); 68 STATIC_REQUIRE(SameAs<based::remove_cv_t<int&>, int&>); 69 STATIC_REQUIRE(SameAs<based::remove_cv_t<int&&>, int&&>); 70 STATIC_REQUIRE(SameAs<based::remove_cv_t<int[2]>, int[2]>); 71 STATIC_REQUIRE(SameAs<based::remove_cv_t<int(&)[2]>, int(&)[2]>); 72 STATIC_REQUIRE(SameAs<based::remove_cv_t<int(&&)[2]>, int(&&)[2]>); 73 STATIC_REQUIRE(SameAs<based::remove_cv_t<const int>, int>); 74 STATIC_REQUIRE(SameAs<based::remove_cv_t<const int&>, const int&>); 75 STATIC_REQUIRE(SameAs<based::remove_cv_t<const int[2]>, int[2]>); 76 STATIC_REQUIRE(SameAs<based::remove_cv_t<const int(&)[2]>, const int(&)[2]>); 77 STATIC_REQUIRE(SameAs<based::remove_cv_t<int(int)>, int(int)>); 78 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int>, int>); 79 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int&>, volatile int&>); 80 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int&&>, volatile int&&>); 81 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int[2]>, int[2]>); 82 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int(&)[2]>, volatile int(&)[2]>); 83 STATIC_REQUIRE(SameAs<based::remove_cv_t<volatile int(&&)[2]>, volatile int(&&)[2]>); 84 STATIC_REQUIRE(SameAs<based::remove_cv_t<const volatile int>, int>); 85 STATIC_REQUIRE(SameAs<based::remove_cv_t<const volatile int&>, volatile const int&>); 86 STATIC_REQUIRE(SameAs<based::remove_cv_t<const volatile int[2]>, int[2]>); 87 STATIC_REQUIRE(SameAs<based::remove_cv_t<const volatile int(&)[2]>, volatile const int(&)[2]>); 88 // clang-format on 89 } 90 91 TEST_CASE("remove_reference", "[type_traits/remove_reference]") 92 { 93 // clang-format off 94 STATIC_REQUIRE(SameAs<based::remove_reference_t<int>, int>); 95 STATIC_REQUIRE(SameAs<based::remove_reference_t<int&>, int>); 96 STATIC_REQUIRE(SameAs<based::remove_reference_t<int&&>, int>); 97 STATIC_REQUIRE(SameAs<based::remove_reference_t<int[2]>, int[2]>); 98 STATIC_REQUIRE(SameAs<based::remove_reference_t<int(&)[2]>, int[2]>); 99 STATIC_REQUIRE(SameAs<based::remove_reference_t<int(&&)[2]>, int[2]>); 100 STATIC_REQUIRE(SameAs<based::remove_reference_t<const int>, const int>); 101 STATIC_REQUIRE(SameAs<based::remove_reference_t<const int&>, const int>); 102 STATIC_REQUIRE(SameAs<based::remove_reference_t<const int[2]>, const int[2]>); 103 STATIC_REQUIRE(SameAs<based::remove_reference_t<const int(&)[2]>, const int[2]>); 104 STATIC_REQUIRE(SameAs<based::remove_reference_t<int(int)>, int(int)>); 105 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int>,volatile int>); 106 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int&>, volatile int>); 107 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int&&>, volatile int>); 108 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int[2]>, volatile int[2]>); 109 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int(&)[2]>, volatile int[2]>); 110 STATIC_REQUIRE(SameAs<based::remove_reference_t<volatile int(&&)[2]>, volatile int[2]>); 111 STATIC_REQUIRE(SameAs<based::remove_reference_t<const volatile int>, const volatile int>); 112 STATIC_REQUIRE(SameAs<based::remove_reference_t<const volatile int&>, volatile const int>); 113 STATIC_REQUIRE(SameAs<based::remove_reference_t<const volatile int[2]>, const volatile int[2]>); 114 STATIC_REQUIRE(SameAs<based::remove_reference_t<const volatile int(&)[2]>, volatile const int[2]>); 115 // clang-format on 116 } 117 118 TEST_CASE("remove_cvref", "[type_traits/remove_cvref]") 119 { 120 // clang-format off 121 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int>, int>); 122 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int&>, int>); 123 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int&&>, int>); 124 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int[2]>, int[2]>); 125 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int(&)[2]>, int[2]>); 126 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int(&&)[2]>, int[2]>); 127 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const int>, int>); 128 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const int&>, int>); 129 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const int[2]>, int[2]>); 130 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const int(&)[2]>, int[2]>); 131 STATIC_REQUIRE(SameAs<based::remove_cvref_t<int(int)>, int(int)>); 132 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int>, int>); 133 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int&>, int>); 134 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int&&>, int>); 135 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int[2]>, int[2]>); 136 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int(&)[2]>, int[2]>); 137 STATIC_REQUIRE(SameAs<based::remove_cvref_t<volatile int(&&)[2]>, int[2]>); 138 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const volatile int>, int>); 139 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const volatile int&>, int>); 140 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const volatile int[2]>, int[2]>); 141 STATIC_REQUIRE(SameAs<based::remove_cvref_t<const volatile int(&)[2]>, int[2]>); 142 // clang-format on 143 } 144 145 TEST_CASE("remove_pointer", "[type_traits/remove_pointer]") 146 { 147 // clang-format off 148 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int>, int>); 149 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int*>, int>); 150 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int**>, int*>); 151 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int* const>, int>); 152 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int* volatile>, int>); 153 STATIC_REQUIRE(SameAs<based::remove_pointer_t<int* const volatile>, int>); 154 // clang-format on 155 } 156 157 // NOLINTEND(*array*)