Test ir::Instruction::GetOperand and GetInOperand
authorDavid Neto <dneto@google.com>
Fri, 26 Aug 2016 14:33:41 +0000 (10:33 -0400)
committerDavid Neto <dneto@google.com>
Fri, 26 Aug 2016 14:59:25 +0000 (10:59 -0400)
test/opt/test_instruction.cpp

index fb64ade..e821068 100644 (file)
@@ -91,6 +91,19 @@ TEST(InstructionTest, CreateWithOpcodeAndOperands) {
   EXPECT_EQ(2u, inst.NumInOperandWords());
 }
 
+TEST(InstructionTest, GetOperand) {
+  Instruction inst(kSampleParsedInstruction);
+  EXPECT_THAT(inst.GetOperand(0).words, Eq(std::vector<uint32_t>{44}));
+  EXPECT_THAT(inst.GetOperand(1).words, Eq(std::vector<uint32_t>{32}));
+  EXPECT_THAT(inst.GetOperand(2).words, Eq(std::vector<uint32_t>{1}));
+}
+
+TEST(InstructionTest, GetInOperand) {
+  Instruction inst(kSampleParsedInstruction);
+  EXPECT_THAT(inst.GetInOperand(0).words, Eq(std::vector<uint32_t>{32}));
+  EXPECT_THAT(inst.GetInOperand(1).words, Eq(std::vector<uint32_t>{1}));
+}
+
 TEST(InstructionTest, OperandConstIterators) {
   Instruction inst(kSampleParsedInstruction);
   // Spot check iteration across operands.