binary parse test: extra words after string literal
authorDavid Neto <dneto@google.com>
Mon, 30 Nov 2015 18:45:20 +0000 (13:45 -0500)
committerDavid Neto <dneto@google.com>
Tue, 1 Dec 2015 20:38:32 +0000 (15:38 -0500)
Covers the case where the string literal is the
last operand.

TODO: Case where one more operand is expected after
the string literal.  Occurs only for the LinkageAttributes
decoration.  To test that, we need to update the grammar
as well.

test/BinaryParse.cpp

index 8c59c86..95b993b 100644 (file)
@@ -547,6 +547,14 @@ INSTANTIATE_TEST_CASE_P(
                       {spvOpcodeMake(3, SpvOpString), 1, 0x41414141, 0}}),
          "Invalid word count: OpString starting at word 5 says it has 3"
          " words, but found 4 words instead."},
+        // Word count is too large.  The string terminates before the last
+        // word.
+        {Concatenate({ExpectedHeaderForBound(2),
+                      {spvOpcodeMake(4, SpvOpString), 1 /* result id */},
+                      MakeVector("abc"),
+                      {0 /* this word does not belong*/}}),
+         "Invalid instruction OpString starting at word 5: expected no more"
+         " operands after 3 words, but stated word count is 4."},
         {Concatenate({ExpectedHeaderForBound(2),
                       {spvOpcodeMake(2, SpvOpTypeVoid), 0}}),
          "Error: Result Id is 0"},