[llvm-nm] - Add a test case for case when we dump a symbol that belongs to a section...
[llvm-complete.git] / unittests / IR / DataLayoutTest.cpp
blobe24e8e045dbd7c6ea85bb053485799fc1620262e
1 //===- ConstantRangeTest.cpp - ConstantRange tests ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/IR/DataLayout.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 namespace {
16 TEST(DataLayoutTest, FunctionPtrAlign) {
17 EXPECT_EQ(MaybeAlign(0), DataLayout("").getFunctionPtrAlign());
18 EXPECT_EQ(MaybeAlign(1), DataLayout("Fi8").getFunctionPtrAlign());
19 EXPECT_EQ(MaybeAlign(2), DataLayout("Fi16").getFunctionPtrAlign());
20 EXPECT_EQ(MaybeAlign(4), DataLayout("Fi32").getFunctionPtrAlign());
21 EXPECT_EQ(MaybeAlign(8), DataLayout("Fi64").getFunctionPtrAlign());
22 EXPECT_EQ(MaybeAlign(1), DataLayout("Fn8").getFunctionPtrAlign());
23 EXPECT_EQ(MaybeAlign(2), DataLayout("Fn16").getFunctionPtrAlign());
24 EXPECT_EQ(MaybeAlign(4), DataLayout("Fn32").getFunctionPtrAlign());
25 EXPECT_EQ(MaybeAlign(8), DataLayout("Fn64").getFunctionPtrAlign());
26 EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
27 DataLayout("").getFunctionPtrAlignType());
28 EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
29 DataLayout("Fi8").getFunctionPtrAlignType());
30 EXPECT_EQ(DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign, \
31 DataLayout("Fn8").getFunctionPtrAlignType());
32 EXPECT_EQ(DataLayout("Fi8"), DataLayout("Fi8"));
33 EXPECT_NE(DataLayout("Fi8"), DataLayout("Fi16"));
34 EXPECT_NE(DataLayout("Fi8"), DataLayout("Fn8"));
36 DataLayout a(""), b("Fi8"), c("Fn8");
37 EXPECT_NE(a, b);
38 EXPECT_NE(a, c);
39 EXPECT_NE(b, c);
41 a = b;
42 EXPECT_EQ(a, b);
43 a = c;
44 EXPECT_EQ(a, c);
47 } // anonymous namespace