Add OpSizeOf tests.

This commit is contained in:
Dejan Mircevski 2016-04-27 15:41:58 -04:00
parent da8222ee4e
commit 45d391b7b1

View File

@ -244,6 +244,36 @@ TEST_F(OpTypeForwardPointerTest, WrongClass) {
Eq("Invalid storage class 'xxyyzz'."));
}
using OpSizeOfTest = spvtest::TextToBinaryTest;
TEST_F(OpSizeOfTest, OpcodeUnrecognizedInV10) {
EXPECT_THAT(CompileFailure("%1 = OpSizeOf %2 %3", SPV_ENV_UNIVERSAL_1_0),
Eq("Invalid Opcode name 'OpSizeOf'"));
}
TEST_F(OpSizeOfTest, ArgumentCount) {
EXPECT_THAT(
CompileFailure("OpSizeOf", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected <result-id> at the beginning of an instruction, found "
"'OpSizeOf'."));
EXPECT_THAT(CompileFailure("%res = OpSizeOf OpNop", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected operand, found next instruction instead."));
EXPECT_THAT(
CompiledInstructions("%1 = OpSizeOf %2 %3", SPV_ENV_UNIVERSAL_1_1),
Eq(MakeInstruction(SpvOpSizeOf, {1, 2, 3})));
EXPECT_THAT(
CompileFailure("%1 = OpSizeOf %2 %3 44 55 ", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected <opcode> or <result-id> at the beginning of an instruction, "
"found '44'."));
}
TEST_F(OpSizeOfTest, ArgumentTypes) {
EXPECT_THAT(CompileFailure("%1 = OpSizeOf 2 %3", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected id to start with %."));
EXPECT_THAT(CompileFailure("%1 = OpSizeOf %2 \"abc\"", SPV_ENV_UNIVERSAL_1_1),
Eq("Expected id to start with %."));
}
// TODO(dneto): OpTypeVoid
// TODO(dneto): OpTypeBool
// TODO(dneto): OpTypeInt