diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-12-31 19:54:45 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2012-12-31 19:54:45 +0000 |
commit | 3c6f89aa2e489b79f16270dae42d10059234cf82 (patch) | |
tree | 0e645e0c6803e47b09fb35a8f929c4178217884b /unittests/Support | |
parent | 44365353a415d37daae9df53fbf6a91677ed90d3 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support')
-rw-r--r-- | unittests/Support/AlignOfTest.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/unittests/Support/AlignOfTest.cpp b/unittests/Support/AlignOfTest.cpp index b518f3b861..40f7295857 100644 --- a/unittests/Support/AlignOfTest.cpp +++ b/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>)); +} } |