From c7beb107850f21701d1f60742ee449b8ffd8fd1c Mon Sep 17 00:00:00 2001 From: Beman Date: Wed, 22 May 2013 08:46:56 -0400 Subject: [PATCH] Add alignment test cases for aligned endian types. --- test/endian_test.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/endian_test.cpp b/test/endian_test.cpp index eb32be8..5688008 100644 --- a/test/endian_test.cpp +++ b/test/endian_test.cpp @@ -58,7 +58,7 @@ namespace cout << "Error: verify size failed on line " << line << endl; cout << " A structure with an expected sizeof() " << expected << " had an actual sizeof() " << actual - << "\n This will cause common uses of to fail\n"; + << "\n This will cause uses of endian types to fail\n"; } template @@ -470,6 +470,24 @@ namespace native_u64_t v31; }; + // aligned test cases + + struct big_aligned_struct + { + big_int16_t v0; + big_int32_t v1; + char v3; + big_int64_t v4; + }; + + struct little_aligned_struct + { + little_int16_t v0; + little_int32_t v1; + char v3; + little_int64_t v4; + }; + int saved_err_count = err_count; VERIFY_SIZE( sizeof(big_struct), 39 ); @@ -478,6 +496,8 @@ namespace VERIFY_SIZE( sizeof(little_u_struct), 39 ); VERIFY_SIZE( sizeof(native_struct), 39 ); VERIFY_SIZE( sizeof(native_u_struct), 39 ); + VERIFY_SIZE( sizeof(big_aligned_struct), 24 ); + VERIFY_SIZE( sizeof(little_aligned_struct), 24 ); if ( saved_err_count == err_count ) {