comparison unittests/Support/Casting.cpp @ 147:c2174574ed3a

LLVM 10
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 16:55:33 +0900
parents 803732b1fca8
children
comparison
equal deleted inserted replaced
134:3a76565eade5 147:c2174574ed3a
1 //===---------- llvm/unittest/Support/Casting.cpp - Casting tests ---------===// 1 //===---------- llvm/unittest/Support/Casting.cpp - Casting tests ---------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // 4 // See https://llvm.org/LICENSE.txt for license information.
5 // This file is distributed under the University of Illinois Open Source 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 8
10 #include "llvm/Support/Casting.h" 9 #include "llvm/Support/Casting.h"
11 #include "llvm/IR/User.h" 10 #include "llvm/IR/User.h"
115 TEST(CastingTest, isa) { 114 TEST(CastingTest, isa) {
116 EXPECT_TRUE(isa<foo>(B1)); 115 EXPECT_TRUE(isa<foo>(B1));
117 EXPECT_TRUE(isa<foo>(B2)); 116 EXPECT_TRUE(isa<foo>(B2));
118 EXPECT_TRUE(isa<foo>(B3)); 117 EXPECT_TRUE(isa<foo>(B3));
119 EXPECT_TRUE(isa<foo>(B4)); 118 EXPECT_TRUE(isa<foo>(B4));
119 }
120
121 TEST(CastingTest, isa_and_nonnull) {
122 EXPECT_TRUE(isa_and_nonnull<foo>(B2));
123 EXPECT_TRUE(isa_and_nonnull<foo>(B4));
124 EXPECT_FALSE(isa_and_nonnull<foo>(fub()));
120 } 125 }
121 126
122 TEST(CastingTest, cast) { 127 TEST(CastingTest, cast) {
123 foo &F1 = cast<foo>(B1); 128 foo &F1 = cast<foo>(B1);
124 EXPECT_NE(&F1, null_foo); 129 EXPECT_NE(&F1, null_foo);