aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/AlignOfTest.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-12-31 19:54:45 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-12-31 19:54:45 +0000
commitda3e31a4196829b5134d2725b6d27ce057ec7831 (patch)
tree5dffb40ffcb352b19ff2490222a28e627df59e3e /llvm/unittests/Support/AlignOfTest.cpp
parentaf463573cbeff293e7f3e72b9fb81d2b447837de (diff)
downloadllvm-da3e31a4196829b5134d2725b6d27ce057ec7831.zip
llvm-da3e31a4196829b5134d2725b6d27ce057ec7831.tar.gz
llvm-da3e31a4196829b5134d2725b6d27ce057ec7831.tar.bz2
[AlignOf] Add AlignedCharArray and refactor AlignedCharArrayUnion.
This adds AlignedCharArray<Alignment, Size>. A templated struct that contains a member named buffer of type char[Size] that is aligned to Alignment. llvm-svn: 171319
Diffstat (limited to 'llvm/unittests/Support/AlignOfTest.cpp')
-rw-r--r--llvm/unittests/Support/AlignOfTest.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp
index b518f3b..40f7295 100644
--- a/llvm/unittests/Support/AlignOfTest.cpp
+++ b/llvm/unittests/Support/AlignOfTest.cpp
@@ -14,7 +14,6 @@
using namespace llvm;
namespace {
-
// Disable warnings about questionable type definitions.
// We're testing that even questionable types work with the alignment utilities.
#ifdef _MSC_VER
@@ -321,6 +320,16 @@ TEST(AlignOfTest, BasicAlignedArray) {
#ifndef _MSC_VER
EXPECT_EQ(sizeof(V8), sizeof(AlignedCharArrayUnion<V8>));
#endif
-}
+ EXPECT_EQ(1u, (alignOf<AlignedCharArray<1, 1> >()));
+ EXPECT_EQ(2u, (alignOf<AlignedCharArray<2, 1> >()));
+ EXPECT_EQ(4u, (alignOf<AlignedCharArray<4, 1> >()));
+ EXPECT_EQ(8u, (alignOf<AlignedCharArray<8, 1> >()));
+ EXPECT_EQ(16u, (alignOf<AlignedCharArray<16, 1> >()));
+
+ EXPECT_EQ(1u, sizeof(AlignedCharArray<1, 1>));
+ EXPECT_EQ(7u, sizeof(AlignedCharArray<1, 7>));
+ EXPECT_EQ(2u, sizeof(AlignedCharArray<2, 2>));
+ EXPECT_EQ(16u, sizeof(AlignedCharArray<2, 16>));
+}
}