1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <stddef.h>
6 
7 #include <limits>
8 
9 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
10 #include "mojo/public/cpp/bindings/lib/serialization_util.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 
13 namespace mojo {
14 namespace test {
15 namespace {
16 
17 // Tests that FixedBuffer allocates memory aligned to 8 byte boundaries.
TEST(FixedBufferTest,Alignment)18 TEST(FixedBufferTest, Alignment) {
19   internal::FixedBufferForTesting buf(internal::Align(10) * 2);
20   ASSERT_EQ(buf.size(), 16u * 2);
21 
22   size_t a = buf.Allocate(10);
23   EXPECT_EQ(0u, a);
24 
25   size_t b = buf.Allocate(10);
26   ASSERT_EQ(16u, b);
27 
28   // Any more allocations would result in an assert, but we can't test that.
29 }
30 
31 }  // namespace
32 }  // namespace test
33 }  // namespace mojo
34