diff options
author | David Neto <dneto@google.com> | 2020-04-27 06:38:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 09:38:06 -0400 |
commit | eed48ae479d17f3cebcd57b41f837fe11971feeb (patch) | |
tree | 401eac19bbfbbd1ff4f35a670df1ef2510bdbb13 /test/opt/instruction_test.cpp | |
parent | 94d6002dc53496d8df2701a784640be16e628812 (diff) | |
download | spirv-tools-eed48ae479d17f3cebcd57b41f837fe11971feeb.tar.gz |
Add spvtools::opt::Operand::AsLiteralUint64 (#3320)
Diffstat (limited to 'test/opt/instruction_test.cpp')
-rw-r--r-- | test/opt/instruction_test.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/opt/instruction_test.cpp b/test/opt/instruction_test.cpp index 1995c5b3..17797204 100644 --- a/test/opt/instruction_test.cpp +++ b/test/opt/instruction_test.cpp @@ -74,6 +74,18 @@ TEST(InstructionTest, OperandAsString) { EXPECT_EQ("abcde", operand.AsString()); } +TEST(InstructionTest, OperandAsLiteralUint64_32bits) { + Operand::OperandData words{0x1234}; + Operand operand(SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER, std::move(words)); + EXPECT_EQ(uint64_t(0x1234), operand.AsLiteralUint64()); +} + +TEST(InstructionTest, OperandAsLiteralUint64_64bits) { + Operand::OperandData words{0x1234, 0x89ab}; + Operand operand(SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER, std::move(words)); + EXPECT_EQ((uint64_t(0x89ab) << 32 | 0x1234), operand.AsLiteralUint64()); +} + // The words for an OpTypeInt for 32-bit signed integer resulting in Id 44. uint32_t kSampleInstructionWords[] = {(4 << 16) | uint32_t(SpvOpTypeInt), 44, 32, 1}; |