Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: mojo/public/c/system/tests/macros_unittest.cc

Issue 295383012: Mojo: Require our public options structs to be aligned like int64_t's. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« mojo/public/c/system/macros.h ('K') | « mojo/public/c/system/macros.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4214325cd7c13f714df62dec6088831210be9db9 100644
--- a/mojo/public/c/system/tests/macros_unittest.cc
+++ b/mojo/public/c/system/tests/macros_unittest.cc
@@ -44,5 +44,28 @@ 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.
+struct MOJO_ALIGNAS(1) StructAlignas1 { char x; };
+struct MOJO_ALIGNAS(4) StructAlignas4 { char x; };
+struct MOJO_ALIGNAS(8) StructAlignas8 { char x; };
+struct MOJO_ALIGNAS(MOJO_ALIGNOF(int64_t)) StructAlignasInt64 { char x; };
+
+TEST(MacrosTest, Alignas) {
+ EXPECT_EQ(1u, MOJO_ALIGNOF(StructAlignas1));
+ EXPECT_EQ(4u, MOJO_ALIGNOF(StructAlignas4));
+ EXPECT_EQ(8u, MOJO_ALIGNOF(StructAlignas8));
+ EXPECT_EQ(MOJO_ALIGNOF(int64_t), MOJO_ALIGNOF(StructAlignasInt64));
+}
+
} // namespace
} // namespace mojo
« mojo/public/c/system/macros.h ('K') | « mojo/public/c/system/macros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698