From f445be8958014c85eb39e07b1e0a389ea9522230 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 17 Jun 2012 09:05:04 +0000 Subject: [PATCH] Add some somewhat exhaustive tests of sizeof properties of this horrible construct just for my sanity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158637 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/AlignOfTest.cpp | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/unittests/Support/AlignOfTest.cpp b/unittests/Support/AlignOfTest.cpp index 461b1d67e06..0d835715652 100644 --- a/unittests/Support/AlignOfTest.cpp +++ b/unittests/Support/AlignOfTest.cpp @@ -252,6 +252,66 @@ TEST(AlignOfTest, BasicAlignedArray) { #ifndef _MSC_VER EXPECT_EQ(alignOf(), alignOf::union_type>()); #endif + + EXPECT_EQ(sizeof(char), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[1]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[2]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[3]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[4]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[5]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[8]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[13]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[16]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[21]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(char[32]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(short), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(int), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(long), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(long long), + sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(float), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(double), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(long double), + sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(void *), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(int *), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(double (*)(double)), + sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(double (S6::*)()), + sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S1), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S2), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S3), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S4), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S5), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(S6), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D1), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D2), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D3), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D4), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D5), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D6), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D7), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D8), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[1]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[2]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[3]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[4]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[5]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[8]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[13]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[16]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[21]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(D9[32]), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V1), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V2), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V3), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V4), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V5), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V6), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V7), sizeof(AlignedCharArray::union_type)); + EXPECT_EQ(sizeof(V8), sizeof(AlignedCharArray::union_type)); } } -- 2.34.1