|
16 | 16 | * limitations under the License.
|
17 | 17 | */
|
18 | 18 |
|
| 19 | +#include <functional> |
| 20 | + |
19 | 21 | #include <lib/support/UnitTestRegistration.h>
|
20 | 22 | #include <lib/support/Variant.h>
|
21 | 23 |
|
@@ -208,6 +210,21 @@ void TestVariantMoveAssign(nlTestSuite * inSuite, void * inContext)
|
208 | 210 | NL_TEST_ASSERT(inSuite, v2.Get<Pod>().m2 == 10);
|
209 | 211 | }
|
210 | 212 |
|
| 213 | +void TestVariantInPlace(nlTestSuite * inSuite, void * inContext) |
| 214 | +{ |
| 215 | + int i = 0; |
| 216 | + |
| 217 | + Variant<std::reference_wrapper<int>> v1 = Variant<std::reference_wrapper<int>>(InPlaceTemplate<std::reference_wrapper<int>>, i); |
| 218 | + NL_TEST_ASSERT(inSuite, v1.Valid()); |
| 219 | + NL_TEST_ASSERT(inSuite, v1.Is<std::reference_wrapper<int>>()); |
| 220 | + NL_TEST_ASSERT(inSuite, &v1.Get<std::reference_wrapper<int>>().get() == &i); |
| 221 | + |
| 222 | + Variant<std::reference_wrapper<int>> v2 = Variant<std::reference_wrapper<int>>::Create<std::reference_wrapper<int>>(i); |
| 223 | + NL_TEST_ASSERT(inSuite, v2.Valid()); |
| 224 | + NL_TEST_ASSERT(inSuite, v2.Is<std::reference_wrapper<int>>()); |
| 225 | + NL_TEST_ASSERT(inSuite, &v2.Get<std::reference_wrapper<int>>().get() == &i); |
| 226 | +} |
| 227 | + |
211 | 228 | void TestVariantCompare(nlTestSuite * inSuite, void * inContext)
|
212 | 229 | {
|
213 | 230 | Variant<Simple, Pod> v0;
|
@@ -268,11 +285,11 @@ int Teardown(void * inContext)
|
268 | 285 | /**
|
269 | 286 | * Test Suite. It lists all the test functions.
|
270 | 287 | */
|
271 |
| -static const nlTest sTests[] = { |
272 |
| - NL_TEST_DEF_FN(TestVariantSimple), NL_TEST_DEF_FN(TestVariantMovable), NL_TEST_DEF_FN(TestVariantCtorDtor), |
273 |
| - NL_TEST_DEF_FN(TestVariantCopy), NL_TEST_DEF_FN(TestVariantMove), NL_TEST_DEF_FN(TestVariantCopyAssign), |
274 |
| - NL_TEST_DEF_FN(TestVariantMoveAssign), NL_TEST_DEF_FN(TestVariantCompare), NL_TEST_SENTINEL() |
275 |
| -}; |
| 288 | +static const nlTest sTests[] = { NL_TEST_DEF_FN(TestVariantSimple), NL_TEST_DEF_FN(TestVariantMovable), |
| 289 | + NL_TEST_DEF_FN(TestVariantCtorDtor), NL_TEST_DEF_FN(TestVariantCopy), |
| 290 | + NL_TEST_DEF_FN(TestVariantMove), NL_TEST_DEF_FN(TestVariantCopyAssign), |
| 291 | + NL_TEST_DEF_FN(TestVariantMoveAssign), NL_TEST_DEF_FN(TestVariantInPlace), |
| 292 | + NL_TEST_DEF_FN(TestVariantCompare), NL_TEST_SENTINEL() }; |
276 | 293 |
|
277 | 294 | int TestVariant()
|
278 | 295 | {
|
|
0 commit comments