TypesTest.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. //===----------------------------------------------------------------------===//
  8. #include "llvm/IR/DerivedTypes.h"
  9. #include "llvm/IR/LLVMContext.h"
  10. #include "gtest/gtest.h"
  11. using namespace llvm;
  12. namespace {
  13. TEST(TypesTest, StructType) {
  14. LLVMContext C;
  15. // PR13522
  16. StructType *Struct = StructType::create(C, "FooBar");
  17. EXPECT_EQ("FooBar", Struct->getName());
  18. Struct->setName(Struct->getName().substr(0, 3));
  19. EXPECT_EQ("Foo", Struct->getName());
  20. Struct->setName("");
  21. EXPECT_TRUE(Struct->getName().empty());
  22. EXPECT_FALSE(Struct->hasName());
  23. }
  24. TEST(TypesTest, LayoutIdenticalEmptyStructs) {
  25. LLVMContext C;
  26. StructType *Foo = StructType::create(C, "Foo");
  27. StructType *Bar = StructType::create(C, "Bar");
  28. EXPECT_TRUE(Foo->isLayoutIdentical(Bar));
  29. }
  30. } // end anonymous namespace