1 //===- llvm/unittest/IR/TypesTest.cpp - Type unit tests -------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/IR/DerivedTypes.h"
10 #include "llvm/IR/LLVMContext.h"
11 #include "gtest/gtest.h"
16 TEST(TypesTest
, StructType
) {
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());
25 EXPECT_TRUE(Struct
->getName().empty());
26 EXPECT_FALSE(Struct
->hasName());
29 TEST(TypesTest
, LayoutIdenticalEmptyStructs
) {
32 StructType
*Foo
= StructType::create(C
, "Foo");
33 StructType
*Bar
= StructType::create(C
, "Bar");
34 EXPECT_TRUE(Foo
->isLayoutIdentical(Bar
));
37 } // end anonymous namespace