brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 445efee Raw
53 lines · cpp
1//===-- rtti_test.cpp -----------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8//9// Note:10//   This unit test was adapted from11//   llvm/unittests/Support/ExtensibleRTTITest.cpp12//13//===----------------------------------------------------------------------===//14 15#include "orc-rt/RTTI.h"16#include "gtest/gtest.h"17 18using namespace orc_rt;19 20namespace {21 22class MyBase : public RTTIExtends<MyBase, RTTIRoot> {};23 24class MyDerivedA : public RTTIExtends<MyDerivedA, MyBase> {};25 26class MyDerivedB : public RTTIExtends<MyDerivedB, MyBase> {};27 28} // end anonymous namespace29 30TEST(ExtensibleRTTITest, BaseCheck) {31  MyBase MB;32  MyDerivedA MDA;33  MyDerivedB MDB;34 35  // Check MB properties.36  EXPECT_TRUE(isa<RTTIRoot>(MB));37  EXPECT_TRUE(isa<MyBase>(MB));38  EXPECT_FALSE(isa<MyDerivedA>(MB));39  EXPECT_FALSE(isa<MyDerivedB>(MB));40 41  // Check MDA properties.42  EXPECT_TRUE(isa<RTTIRoot>(MDA));43  EXPECT_TRUE(isa<MyBase>(MDA));44  EXPECT_TRUE(isa<MyDerivedA>(MDA));45  EXPECT_FALSE(isa<MyDerivedB>(MDA));46 47  // Check MDB properties.48  EXPECT_TRUE(isa<RTTIRoot>(MDB));49  EXPECT_TRUE(isa<MyBase>(MDB));50  EXPECT_FALSE(isa<MyDerivedA>(MDB));51  EXPECT_TRUE(isa<MyDerivedB>(MDB));52}53