From 58e155658e02499b0bf7e4745b6a5e029cf4e8ff Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 8 Feb 2018 16:00:05 +0000 Subject: [PATCH] Alignment tests for conversion operators --- test/test_alignment.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/test_alignment.cpp b/test/test_alignment.cpp index 4f55c829..ba0b25ab 100644 --- a/test/test_alignment.cpp +++ b/test/test_alignment.cpp @@ -67,6 +67,35 @@ namespace f(static_cast(data9)); } + //************************************************************************* + TEST(test_aligned_storage_conversion_operators) + { + typedef etl::aligned_storage::value>::type storage32_t; + static storage32_t data; + + void* pdata = &data.data; + + uint32_t& ref = data; + const uint32_t& cref = data; + CHECK(&ref == pdata); + CHECK(&cref == pdata); + + uint32_t* ptr = data; + const uint32_t* cptr = data; + CHECK(ptr == pdata); + CHECK(cptr == pdata); + + uint32_t& ref2 = data.get_reference(); + const uint32_t& cref2 = data.get_reference(); + CHECK(&ref2 == pdata); + CHECK(&cref2 == pdata); + + uint32_t* ptr2 = data.get_address(); + const uint32_t* cptr2 = data.get_address(); + CHECK(ptr2 == pdata); + CHECK(cptr2 == pdata); + } + //************************************************************************* TEST(test_aligned_storage_as) {