Assembly failure cases for OpMemoryBarrier
authorDavid Neto <dneto@google.com>
Mon, 28 Sep 2015 20:00:42 +0000 (16:00 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
Fully tests OperandMemorySemantics from the syntax table.

test/TextToBinary.Barrier.cpp

index 4449b77..2078064 100644 (file)
@@ -42,13 +42,37 @@ using ::testing::Eq;
 
 using OpMemoryBarrier = spvtest::TextToBinaryTest;
 
-TEST_F(OpMemoryBarrier, Sample) {
+TEST_F(OpMemoryBarrier, Good) {
   std::string input = "OpMemoryBarrier %1 %2\n";
   EXPECT_THAT(CompiledInstructions(input),
               Eq(MakeInstruction(spv::OpMemoryBarrier, {1, 2})));
   EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
 }
 
+TEST_F(OpMemoryBarrier, BadMissingScopeId) {
+  std::string input = "OpMemoryBarrier\n";
+  EXPECT_THAT(CompileFailure(input),
+              Eq("Expected operand, found end of stream."));
+}
+
+TEST_F(OpMemoryBarrier, BadInvalidScopeId) {
+  std::string input = "OpMemoryBarrier 99\n";
+  EXPECT_THAT(CompileFailure(input),
+              Eq("Expected id to start with %."));
+}
+
+TEST_F(OpMemoryBarrier, BadMissingMemorySemanticsId) {
+  std::string input = "OpMemoryBarrier %scope\n";
+  EXPECT_THAT(CompileFailure(input),
+              Eq("Expected operand, found end of stream."));
+}
+
+TEST_F(OpMemoryBarrier, BadInvalidMemorySemanticsId) {
+  std::string input = "OpMemoryBarrier %scope 14\n";
+  EXPECT_THAT(CompileFailure(input),
+              Eq("Expected id to start with %."));
+}
+
 // TODO(dneto): OpControlBarrier
 // TODO(dneto): OpAsyncGroupCopy
 // TODO(dneto): OpWaitGroupEvents