Mercurial > hg > CbC > CbC_llvm
comparison unittests/ADT/PointerIntPairTest.cpp @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 803732b1fca8 |
children |
comparison
equal
deleted
inserted
replaced
134:3a76565eade5 | 147:c2174574ed3a |
---|---|
1 //===- llvm/unittest/ADT/PointerIntPairTest.cpp - Unit tests --------------===// | 1 //===- llvm/unittest/ADT/PointerIntPairTest.cpp - Unit tests --------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 | 8 |
10 #include "llvm/ADT/PointerIntPair.h" | 9 #include "llvm/ADT/PointerIntPair.h" |
11 #include "gtest/gtest.h" | 10 #include "gtest/gtest.h" |
60 EXPECT_EQ(E::Case2, Pair2.getInt()); | 59 EXPECT_EQ(E::Case2, Pair2.getInt()); |
61 | 60 |
62 Pair2.setPointerAndInt(&s, E::Case3); | 61 Pair2.setPointerAndInt(&s, E::Case3); |
63 EXPECT_EQ(&s, Pair2.getPointer()); | 62 EXPECT_EQ(&s, Pair2.getPointer()); |
64 EXPECT_EQ(E::Case3, Pair2.getInt()); | 63 EXPECT_EQ(E::Case3, Pair2.getInt()); |
64 | |
65 static_assert(is_trivially_copyable<PointerIntPair<S *, 2, E>>::value, | |
66 "trivially copyable"); | |
65 } | 67 } |
66 | 68 |
67 TEST(PointerIntPairTest, DefaultInitialize) { | 69 TEST(PointerIntPairTest, DefaultInitialize) { |
68 PointerIntPair<float *, 2> Pair; | 70 PointerIntPair<float *, 2> Pair; |
69 EXPECT_EQ(nullptr, Pair.getPointer()); | 71 EXPECT_EQ(nullptr, Pair.getPointer()); |
95 EXPECT_EQ((uintptr_t)0x7FFFFFFF, pair.getPointer().Value); | 97 EXPECT_EQ((uintptr_t)0x7FFFFFFF, pair.getPointer().Value); |
96 EXPECT_TRUE(pair.getInt()); | 98 EXPECT_TRUE(pair.getInt()); |
97 | 99 |
98 EXPECT_EQ(FixnumPointerTraits::NumLowBitsAvailable - 1, | 100 EXPECT_EQ(FixnumPointerTraits::NumLowBitsAvailable - 1, |
99 PointerLikeTypeTraits<decltype(pair)>::NumLowBitsAvailable); | 101 PointerLikeTypeTraits<decltype(pair)>::NumLowBitsAvailable); |
102 | |
103 static_assert( | |
104 is_trivially_copyable< | |
105 PointerIntPair<Fixnum31, 1, bool, FixnumPointerTraits>>::value, | |
106 "trivially copyable"); | |
100 } | 107 } |
101 | 108 |
102 } // end anonymous namespace | 109 } // end anonymous namespace |