Line data Source code
1 : // Copyright 2017 the V8 project 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 "src/base/macros.h"
6 : #include "testing/gtest/include/gtest/gtest.h"
7 :
8 : namespace v8 {
9 : namespace base {
10 :
11 15373 : TEST(AlignedAddressTest, AlignedAddress) {
12 2 : EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
13 0 : AlignedAddress(reinterpret_cast<void*>(0xFFFF0), 16));
14 2 : EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
15 0 : AlignedAddress(reinterpret_cast<void*>(0xFFFF2), 16));
16 2 : EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
17 0 : AlignedAddress(reinterpret_cast<void*>(0xFFFF2), 16));
18 2 : EXPECT_EQ(reinterpret_cast<void*>(0xFFFF0),
19 0 : AlignedAddress(reinterpret_cast<void*>(0xFFFFF), 16));
20 2 : EXPECT_EQ(reinterpret_cast<void*>(0x0),
21 0 : AlignedAddress(reinterpret_cast<void*>(0xFFFFF), 0x100000));
22 1 : }
23 :
24 : struct TriviallyCopyable {
25 : const int i;
26 : };
27 : ASSERT_TRIVIALLY_COPYABLE(TriviallyCopyable);
28 :
29 : struct StillTriviallyCopyable {
30 : const int i;
31 : StillTriviallyCopyable(const StillTriviallyCopyable&) = delete;
32 : };
33 : ASSERT_TRIVIALLY_COPYABLE(StillTriviallyCopyable);
34 :
35 : struct NonTrivialDestructor {
36 : ~NonTrivialDestructor() {}
37 : };
38 : ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialDestructor);
39 :
40 : struct NonTrivialCopyConstructor {
41 : NonTrivialCopyConstructor(const NonTrivialCopyConstructor&) {}
42 : };
43 : ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyConstructor);
44 :
45 : struct NonTrivialMoveConstructor {
46 : NonTrivialMoveConstructor(const NonTrivialMoveConstructor&) {}
47 : };
48 : ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveConstructor);
49 :
50 : struct NonTrivialCopyAssignment {
51 : NonTrivialCopyAssignment(const NonTrivialCopyAssignment&) {}
52 : };
53 : ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialCopyAssignment);
54 :
55 : struct NonTrivialMoveAssignment {
56 : NonTrivialMoveAssignment(const NonTrivialMoveAssignment&) {}
57 : };
58 : ASSERT_NOT_TRIVIALLY_COPYABLE(NonTrivialMoveAssignment);
59 :
60 : } // namespace base
61 9222 : } // namespace v8
|