aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-03-16 15:53:58 +0000
committerGabor Greif <ggreif@gmail.com>2010-03-16 15:53:58 +0000
commitabf657f7e6dbce1bf8e02fce2d602f33d5fc5c2a (patch)
tree22d8430282f58d4d481dffc13d093f6ab3bece71 /unittests
parentc613969122d3fdebfa87a1b902b719386f4e3009 (diff)
downloadexternal_llvm-abf657f7e6dbce1bf8e02fce2d602f33d5fc5c2a.zip
external_llvm-abf657f7e6dbce1bf8e02fce2d602f33d5fc5c2a.tar.gz
external_llvm-abf657f7e6dbce1bf8e02fce2d602f33d5fc5c2a.tar.bz2
more BranchInst tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/VMCore/InstructionsTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp
index 800511e..054193f 100644
--- a/unittests/VMCore/InstructionsTest.cpp
+++ b/unittests/VMCore/InstructionsTest.cpp
@@ -50,10 +50,17 @@ TEST(InstructionsTest, BranchInst) {
// Mandatory BranchInst
const BranchInst* b0 = BranchInst::Create(bb0);
+ EXPECT_TRUE(b0->isUnconditional());
+ EXPECT_FALSE(b0->isConditional());
+ EXPECT_EQ(b0->getNumSuccessors(), 1U);
+
// check num operands
EXPECT_EQ(b0->getNumOperands(), 1U);
EXPECT_NE(b0->op_begin(), b0->op_end());
+ EXPECT_EQ(b0->op_begin() + 1, b0->op_end());
+
+ EXPECT_EQ(b0->op_begin() + 1, b0->op_end());
const IntegerType* Int1 = IntegerType::get(C, 1);
Constant* One = ConstantInt::get(Int1, 1, true);
@@ -61,6 +68,10 @@ TEST(InstructionsTest, BranchInst) {
// Conditional BranchInst
BranchInst* b1 = BranchInst::Create(bb0, bb1, One);
+ EXPECT_FALSE(b1->isUnconditional());
+ EXPECT_TRUE(b1->isConditional());
+ EXPECT_EQ(b1->getNumSuccessors(), 2U);
+
// check num operands
EXPECT_EQ(b1->getNumOperands(), 3U);
@@ -70,16 +81,19 @@ TEST(InstructionsTest, BranchInst) {
EXPECT_NE(b, b1->op_end());
EXPECT_EQ(*b, One);
EXPECT_EQ(b1->getOperand(0), One);
+ EXPECT_EQ(b1->getCondition(), One);
++b;
// check ELSE
EXPECT_EQ(*b, bb1);
EXPECT_EQ(b1->getOperand(1), bb1);
+ EXPECT_EQ(b1->getSuccessor(1), bb1);
++b;
// check THEN
EXPECT_EQ(*b, bb0);
EXPECT_EQ(b1->getOperand(2), bb0);
+ EXPECT_EQ(b1->getSuccessor(0), bb0);
++b;
EXPECT_EQ(b, b1->op_end());
@@ -96,6 +110,7 @@ TEST(InstructionsTest, BranchInst) {
// check THEN
EXPECT_EQ(*c, bb1);
EXPECT_EQ(b1->getOperand(0), bb1);
+ EXPECT_EQ(b1->getSuccessor(0), bb1);
++c;
EXPECT_EQ(c, b1->op_end());