From: Dejan Mircevski Date: Wed, 27 Apr 2016 19:41:58 +0000 (-0400) Subject: Add OpSizeOf tests. X-Git-Tag: upstream/2018.6~1253 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45d391b7b17fcd2643f05d5505512c9e3c9ea06f;p=platform%2Fupstream%2FSPIRV-Tools.git Add OpSizeOf tests. --- diff --git a/test/TextToBinary.TypeDeclaration.cpp b/test/TextToBinary.TypeDeclaration.cpp index 584c225..05ad9b2 100644 --- a/test/TextToBinary.TypeDeclaration.cpp +++ b/test/TextToBinary.TypeDeclaration.cpp @@ -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 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 or 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