1//===-- extensible_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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of the ORC runtime.
10//
11// Note:
12//   This unit test was adapted from
13//   llvm/unittests/Support/ExtensibleRTTITest.cpp
14//
15//===----------------------------------------------------------------------===//
16
17#include "extensible_rtti.h"
18#include "gtest/gtest.h"
19
20using namespace __orc_rt;
21
22namespace {
23
24class MyBase : public RTTIExtends<MyBase, RTTIRoot> {};
25
26class MyDerivedA : public RTTIExtends<MyDerivedA, MyBase> {};
27
28class MyDerivedB : public RTTIExtends<MyDerivedB, MyBase> {};
29
30} // end anonymous namespace
31
32TEST(ExtensibleRTTITest, BaseCheck) {
33  MyBase MB;
34  MyDerivedA MDA;
35  MyDerivedB MDB;
36
37  // Check MB properties.
38  EXPECT_TRUE(isa<RTTIRoot>(MB));
39  EXPECT_TRUE(isa<MyBase>(MB));
40  EXPECT_FALSE(isa<MyDerivedA>(MB));
41  EXPECT_FALSE(isa<MyDerivedB>(MB));
42
43  // Check MDA properties.
44  EXPECT_TRUE(isa<RTTIRoot>(MDA));
45  EXPECT_TRUE(isa<MyBase>(MDA));
46  EXPECT_TRUE(isa<MyDerivedA>(MDA));
47  EXPECT_FALSE(isa<MyDerivedB>(MDA));
48
49  // Check MDB properties.
50  EXPECT_TRUE(isa<RTTIRoot>(MDB));
51  EXPECT_TRUE(isa<MyBase>(MDB));
52  EXPECT_FALSE(isa<MyDerivedA>(MDB));
53  EXPECT_TRUE(isa<MyDerivedB>(MDB));
54}
55