Negative test for SourceLanguage.
authorDejan Mircevski <deki@google.com>
Fri, 9 Oct 2015 15:06:10 +0000 (11:06 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
Also, use "class" instead of "type" in the coverage CSV.

source/operand.cpp
test/TextToBinary.Debug.cpp
test/operand-class-test-coverage.csv

index e7b39a3..e57fa0c 100644 (file)
@@ -1520,7 +1520,7 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
     case SPV_OPERAND_TYPE_LITERAL_STRING:
       return "literal string";
     case SPV_OPERAND_TYPE_SOURCE_LANGUAGE:
-      return "source langauge";
+      return "source language";
     case SPV_OPERAND_TYPE_EXECUTION_MODEL:
       return "execution model";
     case SPV_OPERAND_TYPE_ADDRESSING_MODEL:
index 0985903..145e04f 100644 (file)
@@ -73,14 +73,20 @@ using OpSourceTest =
 TEST_P(OpSourceTest, AnyLanguage) {
   std::string input = std::string("OpSource ") + GetParam().language_name +
                       " " + std::to_string(GetParam().version);
-  EXPECT_THAT(CompiledInstructions(input),
-              Eq(MakeInstruction(spv::OpSource, {GetParam().get_language_value(),
-                                                 GetParam().version})));
+  EXPECT_THAT(
+      CompiledInstructions(input),
+      Eq(MakeInstruction(spv::OpSource, {GetParam().get_language_value(),
+                                         GetParam().version})));
 }
 
 INSTANTIATE_TEST_CASE_P(TextToBinaryTestDebug, OpSourceTest,
                         ::testing::ValuesIn(kLanguageCases));
 
+TEST_F(OpSourceTest, WrongLanguage) {
+  EXPECT_THAT(CompileFailure("OpSource xxyyzz 12345"),
+              Eq("Invalid source language 'xxyyzz'."));
+}
+
 TEST_F(TextToBinaryTest, OpSourceAcceptsOptionalFileId) {
   // In the grammar, the file id is an OperandOptionalId.
   std::string input = "OpSource GLSL 450 %file_id";
index 0a4ca4f..2a22f8d 100644 (file)
@@ -1,4 +1,4 @@
-Operand type,Example instruction,Notes,example unit test\r
+Operand class,Example instruction,Notes,example unit test\r
 ,,,\r
 ,,,\r
 "    OperandNone,",UNUSED,not in grammar,\r
@@ -42,4 +42,4 @@ Operand type,Example instruction,Notes,example unit test
 "    OperandGroupOperation,",GroupIAdd,,GroupOperationTest\r
 "    OperandKernelEnqueueFlags,",OpEnqueueKernel,"it's an ID, not in grammar",should not have one\r
 "    OperandKernelProfilingInfo,",OpCaptureEventProfilingInfo,"it's an ID, not in grammar",should not have one\r
-"    OperandCapability,",Capability,,OpCapabilityTest
\ No newline at end of file
+"    OperandCapability,",Capability,,OpCapabilityTest\r