Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / unittests / IR / TypesTest.cpp
bloba147367934fa1fc874002f4b74dc6173cae47892
1 //===- llvm/unittest/IR/TypesTest.cpp - Type unit 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/DerivedTypes.h"
10 #include "llvm/IR/LLVMContext.h"
11 #include "gtest/gtest.h"
12 using namespace llvm;
14 namespace {
16 TEST(TypesTest, StructType) {
17 LLVMContext C;
19 // PR13522
20 StructType *Struct = StructType::create(C, "FooBar");
21 EXPECT_EQ("FooBar", Struct->getName());
22 Struct->setName(Struct->getName().substr(0, 3));
23 EXPECT_EQ("Foo", Struct->getName());
24 Struct->setName("");
25 EXPECT_TRUE(Struct->getName().empty());
26 EXPECT_FALSE(Struct->hasName());
29 TEST(TypesTest, LayoutIdenticalEmptyStructs) {
30 LLVMContext C;
32 StructType *Foo = StructType::create(C, "Foo");
33 StructType *Bar = StructType::create(C, "Bar");
34 EXPECT_TRUE(Foo->isLayoutIdentical(Bar));
37 } // end anonymous namespace