From: Lei Zhang Date: Thu, 15 Oct 2015 19:20:45 +0000 (-0400) Subject: Simplify methods for compilation failure in test framework. X-Git-Tag: upstream/2018.6~1511^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c2db8347ec71afca48b90cc4ad0f740bccedbc3;p=platform%2Fupstream%2FSPIRV-Tools.git Simplify methods for compilation failure in test framework. Remove CompileWithFormatFailure() and make CompileFailure() accept a default argument. --- diff --git a/test/TestFixture.h b/test/TestFixture.h index 714994d..8711e6e 100644 --- a/test/TestFixture.h +++ b/test/TestFixture.h @@ -86,8 +86,9 @@ class TextToBinaryTestBase : public T { // Compiles SPIR-V text with the given format, asserting compilation failure. // Returns the error message(s). - std::string CompileWithFormatFailure(const std::string& text, - spv_assembly_syntax_format_t format) { + std::string CompileFailure(const std::string& text, + spv_assembly_syntax_format_t format = + SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT) { EXPECT_NE(SPV_SUCCESS, spvTextWithFormatToBinary(text.c_str(), text.size(), format, opcodeTable, operandTable, extInstTable, @@ -97,12 +98,6 @@ class TextToBinaryTestBase : public T { return diagnostic->error; } - // Compiles SPIR-V text using the default format, asserting compilation failure. - // Returns the error message(s). - std::string CompileFailure(const std::string& text) { - return CompileWithFormatFailure(text, SPV_ASSEMBLY_SYNTAX_FORMAT_DEFAULT); - } - // Encodes SPIR-V text into binary and then decodes the binary. Returns the // decoded text. std::string EncodeAndDecodeSuccessfully(const std::string& text) { diff --git a/test/TextToBinary.ControlFlow.cpp b/test/TextToBinary.ControlFlow.cpp index 62bec7e..976bb1c 100644 --- a/test/TextToBinary.ControlFlow.cpp +++ b/test/TextToBinary.ControlFlow.cpp @@ -176,10 +176,9 @@ TEST_F(TextToBinaryTest, SwitchBadInvalidLiteralCanonicalFormat) { const auto input = R"(OpTypeInt %i32 32 0 OpConstant %i32 %selector 42 OpSwitch %selector %default %abc)"; - EXPECT_THAT( - CompileWithFormatFailure(input, SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL), - Eq("Expected at the beginning of an instruction, found " - "'%abc'.")); + EXPECT_THAT(CompileFailure(input, SPV_ASSEMBLY_SYNTAX_FORMAT_CANONICAL), + Eq("Expected at the beginning of an instruction, found " + "'%abc'.")); } TEST_F(TextToBinaryTest, SwitchBadMissingTarget) { @@ -280,16 +279,15 @@ INSTANTIATE_TEST_CASE_P( MakeSwitchTestCase(48, 0, "0x800000000000", {0x00000000, 0x00008000}, "0x800000000000", {0x00000000, 0x00008000}), MakeSwitchTestCase(63, 0, "0x500000000", {0, 5}, "12", {12, 0}), - MakeSwitchTestCase(64, 0, "0x600000000", { 0, 6 }, "12", {12, 0}), - MakeSwitchTestCase(64, 1, "0x700000123", { 0x123, 7 }, "12", {12, 0}), + MakeSwitchTestCase(64, 0, "0x600000000", {0, 6}, "12", {12, 0}), + MakeSwitchTestCase(64, 1, "0x700000123", {0x123, 7}, "12", {12, 0}), }))); using RoundTripTest = spvtest::TextToBinaryTestBase<::testing::TestWithParam>; TEST_P(RoundTripTest, Sample) { - EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), - Eq(GetParam())); + EXPECT_THAT(EncodeAndDecodeSuccessfully(GetParam()), Eq(GetParam())); } // TODO(dneto): Enable this test.