TypesTest.cpp 852 B

123456789101112131415161718192021222324252627282930
  1. //===- llvm/unittest/IR/TypesTest.cpp - Type unit tests -------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "llvm/IR/DerivedTypes.h"
  10. #include "llvm/IR/LLVMContext.h"
  11. #include "gtest/gtest.h"
  12. using namespace llvm;
  13. namespace {
  14. TEST(TypesTest, StructType) {
  15. LLVMContext C;
  16. // PR13522
  17. StructType *Struct = StructType::create(C, "FooBar");
  18. EXPECT_EQ("FooBar", Struct->getName());
  19. Struct->setName(Struct->getName().substr(0, 3));
  20. EXPECT_EQ("Foo", Struct->getName());
  21. Struct->setName("");
  22. EXPECT_TRUE(Struct->getName().empty());
  23. EXPECT_FALSE(Struct->hasName());
  24. }
  25. } // end anonymous namespace