From 6df2adf079921c56b6281ab1cdecf25bba6aeac4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 12 Jun 2017 23:35:11 +0100 Subject: [PATCH] reference_wrapper test --- test/test_functional.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/test/test_functional.cpp b/test/test_functional.cpp index cf2f19d1..ef3604c0 100644 --- a/test/test_functional.cpp +++ b/test/test_functional.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include namespace -{ +{ SUITE(test_functional) { //************************************************************************* @@ -53,16 +53,40 @@ namespace CHECK_EQUAL(2, ra); } + //************************************************************************* + TEST(test_reference_wrapper_vector) + { + std::vector> ref_int; + + int a = 1; + int b = 2; + + ref_int.push_back(etl::ref(a)); + ref_int.push_back(etl::ref(b)); + + CHECK_EQUAL(a, ref_int[0]); + CHECK_EQUAL(b, ref_int[1]); + + ref_int[0] = 3; + ref_int[1] = 4; + + CHECK_EQUAL(3, a); + CHECK_EQUAL(4, b); + + CHECK_EQUAL(3, ref_int[0]); + CHECK_EQUAL(4, ref_int[1]); + } + //************************************************************************* TEST(test_reference_wrapper_container) { - std::list test = { 0, 1, 2, 3, 4 }; + std::list test = { 0, 1, 2, 3, 4 }; std::list compare = { 5, 6, 7, 8, 9 }; std::vector> test_ref(test.begin(), test.end()); - + std::iota(test_ref.begin(), test_ref.end(), 5); - std::list::const_iterator itest = test.begin(); + std::list::const_iterator itest = test.begin(); std::list::const_iterator icompare = compare.begin(); std::vector>::const_iterator ivector = test_ref.begin();