| Index: mojo/public/c/system/tests/macros_unittest.cc
|
| diff --git a/mojo/public/c/system/tests/macros_unittest.cc b/mojo/public/c/system/tests/macros_unittest.cc
|
| index 5225b67cdbf7371158f32dca80ab4678630fe3b0..fdc0c87c99c2d40a40b15f1a5681a2078cc15f81 100644
|
| --- a/mojo/public/c/system/tests/macros_unittest.cc
|
| +++ b/mojo/public/c/system/tests/macros_unittest.cc
|
| @@ -44,5 +44,34 @@ TEST(MacrosTest, CompileAssert) {
|
| bad_compile_assert_failure);
|
| }
|
|
|
| +TEST(MacrosTest, Alignof) {
|
| + // Strictly speaking, this isn't a portable test, but I think it'll pass on
|
| + // all the platforms we currently support.
|
| + EXPECT_EQ(1u, MOJO_ALIGNOF(char));
|
| + EXPECT_EQ(4u, MOJO_ALIGNOF(int32_t));
|
| + EXPECT_EQ(8u, MOJO_ALIGNOF(int64_t));
|
| + EXPECT_EQ(8u, MOJO_ALIGNOF(double));
|
| +}
|
| +
|
| +// These structs are used in the Alignas test. Define them globally to avoid
|
| +// MSVS warnings/errors.
|
| +#if defined(_MSC_VER)
|
| +#pragma warning(push)
|
| +// Disable the warning "structure was padded due to __declspec(align())".
|
| +#pragma warning(disable:4324)
|
| +#endif
|
| +struct MOJO_ALIGNAS(1) StructAlignas1 { char x; };
|
| +struct MOJO_ALIGNAS(4) StructAlignas4 { char x; };
|
| +struct MOJO_ALIGNAS(8) StructAlignas8 { char x; };
|
| +#if defined(_MSC_VER)
|
| +#pragma warning(pop)
|
| +#endif
|
| +
|
| +TEST(MacrosTest, Alignas) {
|
| + EXPECT_EQ(1u, MOJO_ALIGNOF(StructAlignas1));
|
| + EXPECT_EQ(4u, MOJO_ALIGNOF(StructAlignas4));
|
| + EXPECT_EQ(8u, MOJO_ALIGNOF(StructAlignas8));
|
| +}
|
| +
|
| } // namespace
|
| } // namespace mojo
|
|
|