summaryrefslogtreecommitdiff
path: root/unittests/CodeGen/MachineOperandTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/CodeGen/MachineOperandTest.cpp')
-rw-r--r--unittests/CodeGen/MachineOperandTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/unittests/CodeGen/MachineOperandTest.cpp b/unittests/CodeGen/MachineOperandTest.cpp
index 46f50ab0151..aed60c0a3d6 100644
--- a/unittests/CodeGen/MachineOperandTest.cpp
+++ b/unittests/CodeGen/MachineOperandTest.cpp
@@ -181,4 +181,20 @@ TEST(MachineOperandTest, PrintTargetIndexName) {
}
}
+TEST(MachineOperandTest, PrintJumpTableIndex) {
+ // Create a MachineOperand with a jump-table index and print it.
+ MachineOperand MO = MachineOperand::CreateJTI(3);
+
+ // Checking some preconditions on the newly created
+ // MachineOperand.
+ ASSERT_TRUE(MO.isJTI());
+ ASSERT_TRUE(MO.getIndex() == 3);
+
+ // Print a MachineOperand containing a jump-table index.
+ std::string str;
+ raw_string_ostream OS(str);
+ MO.print(OS, /*TRI=*/nullptr, /*IntrinsicInfo=*/nullptr);
+ ASSERT_TRUE(OS.str() == "%jump-table.3");
+}
+
} // end namespace