[llvm-commits] [llvm] r98634 - /llvm/trunk/unittests/VMCore/InstructionsTest.cpp

Nick Lewycky nicholas at mxc.ca
Tue Mar 16 21:32:54 PDT 2010


Gabor Greif wrote:
> Author: ggreif
> Date: Tue Mar 16 10:53:58 2010
> New Revision: 98634
>
> URL: http://llvm.org/viewvc/llvm-project?rev=98634&view=rev
> Log:
> more BranchInst tests
>
> Modified:
>      llvm/trunk/unittests/VMCore/InstructionsTest.cpp
>
> Modified: llvm/trunk/unittests/VMCore/InstructionsTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/InstructionsTest.cpp?rev=98634&r1=98633&r2=98634&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/VMCore/InstructionsTest.cpp (original)
> +++ llvm/trunk/unittests/VMCore/InstructionsTest.cpp Tue Mar 16 10:53:58 2010
> @@ -50,10 +50,17 @@
>     // 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());

Consider using llvm::next(b0->op_begin()) defined in 
include/llvm/ADT/STLExtras.h .

I'm assuming that this test passes for you, but I don't normally expect 
that I can take iterator + 1 in LLVM because it often gets me a pointer 
addition.

Nick

> +
> +  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 @@
>     // 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 @@
>     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 @@
>     // 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());
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list