Let EncodeAndDecodeSuccessfully remove preamble comments.
authorLei Zhang <antiagainst@google.com>
Thu, 17 Sep 2015 22:24:53 +0000 (18:24 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
test/TestFixture.h
test/TextToBinary.Literal.cpp
test/TextToBinary.cpp

index c142da9..2eb48f0 100644 (file)
@@ -121,7 +121,10 @@ class TextToBinaryTestBase : public T {
     const std::string decoded_string = decoded_text->str;
     spvTextDestroy(decoded_text);
 
-    return decoded_string;
+    // Remove the preamble comments generated by disassembler.
+    const std::string schema0 = "Schema: 0\n";
+    std::string::size_type preamble_end = decoded_string.find(schema0);
+    return decoded_string.substr(preamble_end + schema0.size());
   }
 
   // Compiles SPIR-V text, asserts success, and returns the words representing
index 50cc2ca..bff4c72 100644 (file)
@@ -55,10 +55,7 @@ TEST_F(TextToBinaryTest, LiteralNumberInPlaceOfLiteralString) {
 TEST_F(TextToBinaryTest, DISABLED_LiteralStringTooLong) {
   const std::string code =
       "OpSourceExtension \"" + std::string(65534, 'o') + "\"\n";
-  const std::string header =
-      "; SPIR-V\n; Version: 99\n; Generator: Khronos\n; "
-      "Bound: 1\n; Schema: 0\n";
-  EXPECT_EQ(header + code, EncodeAndDecodeSuccessfully(code));
+  EXPECT_EQ(code, EncodeAndDecodeSuccessfully(code));
 }
 
 }  // anonymous namespace
index cbad557..5e96b1d 100644 (file)
@@ -109,9 +109,9 @@ TEST_P(BadFPFastMathMaskParseTest, BadMaskExpressions) {
   ASSERT_EQ(SPV_SUCCESS, spvOperandTableGet(&operandTable));
 
   uint32_t value;
-  EXPECT_NE(SPV_SUCCESS, spvTextParseMaskOperand(operandTable,
-                                             SPV_OPERAND_TYPE_FP_FAST_MATH_MODE,
-                                             GetParam(), &value));
+  EXPECT_NE(SPV_SUCCESS, spvTextParseMaskOperand(
+                             operandTable, SPV_OPERAND_TYPE_FP_FAST_MATH_MODE,
+                             GetParam(), &value));
 }
 
 INSTANTIATE_TEST_CASE_P(ParseMask, BadFPFastMathMaskParseTest,
@@ -132,7 +132,7 @@ TEST(TextToBinary, Default) {
   // little endian for encoding comparison!
   spv_endianness_t endian = SPV_ENDIANNESS_LITTLE;
 
-  const char *textStr = R"(
+  const chartextStr = R"(
       OpSource OpenCL 12
       OpMemoryModel Physical64 OpenCL
       OpSourceExtension "PlaceholderExtensionName"
@@ -469,8 +469,6 @@ TEST_P(TextToBinaryFloatValueTest, NormalValues) {
   const std::string assembly = "%1 = OpTypeFloat 32\n%2 = OpConstant %1 ";
   const std::string input_string = assembly + GetParam().first;
   const std::string expected_string =
-      "; SPIR-V\n; Version: 99\n; Generator: Khronos\n; "
-      "Bound: 3\n; Schema: 0\n" +
       assembly + std::to_string(GetParam().second) + "\n";
   const std::string decoded_string = EncodeAndDecodeSuccessfully(input_string);
   EXPECT_EQ(expected_string, decoded_string);