From ab778dc1dc7a08bcdcbdb2d99b0354bdb2bf8980 Mon Sep 17 00:00:00 2001 From: David Neto Date: Mon, 28 Sep 2015 11:22:23 -0400 Subject: [PATCH] Cleanup: Use EnumCase for ExecutionMode test --- test/TextToBinary.ModeSetting.cpp | 98 ++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 54 deletions(-) diff --git a/test/TextToBinary.ModeSetting.cpp b/test/TextToBinary.ModeSetting.cpp index f60f461..6e24935 100644 --- a/test/TextToBinary.ModeSetting.cpp +++ b/test/TextToBinary.ModeSetting.cpp @@ -131,71 +131,61 @@ INSTANTIATE_TEST_CASE_P(TextToBinaryEntryPoint, OpEntryPointTest, // Test OpExecutionMode -// A single test case for a simple OpExecutionMode. -// An execution mode has no operands, or just literal numbers as operands. -struct ExecutionModeCase { - uint32_t get_mode_value() const { return static_cast(mode_value); } - spv::ExecutionMode mode_value; - std::string mode_name; - std::vector operands; -}; - using OpExecutionModeTest = spvtest::TextToBinaryTestBase< - ::testing::TestWithParam>; + ::testing::TestWithParam>>; TEST_P(OpExecutionModeTest, AnyExecutionMode) { // This string should assemble, but should not validate. std::stringstream input; - input << "OpExecutionMode %1 " << GetParam().mode_name; - for (auto operand : GetParam().operands) input << " " << operand; - std::vector expected_operands{1, GetParam().get_mode_value()}; - expected_operands.insert(expected_operands.end(), GetParam().operands.begin(), - GetParam().operands.end()); + input << "OpExecutionMode %1 " << GetParam().name(); + for (auto operand : GetParam().operands()) input << " " << operand; + std::vector expected_operands{1, GetParam().value()}; + expected_operands.insert(expected_operands.end(), GetParam().operands().begin(), + GetParam().operands().end()); EXPECT_THAT(CompiledInstructions(input.str()), Eq(MakeInstruction(spv::OpExecutionMode, expected_operands))); } -// clang-format off #define CASE(NAME) spv::ExecutionMode##NAME, #NAME -INSTANTIATE_TEST_CASE_P(TextToBinaryExecutionMode, OpExecutionModeTest, - ::testing::ValuesIn(std::vector{ - // The operand literal values are arbitrarily chosen, - // but there are the right number of them. - {CASE(Invocations), {101}}, - {CASE(SpacingEqual), {}}, - {CASE(SpacingFractionalEven), {}}, - {CASE(SpacingFractionalOdd), {}}, - {CASE(VertexOrderCw), {}}, - {CASE(VertexOrderCcw), {}}, - {CASE(PixelCenterInteger), {}}, - {CASE(OriginUpperLeft), {}}, - {CASE(OriginLowerLeft), {}}, - {CASE(EarlyFragmentTests), {}}, - {CASE(PointMode), {}}, - {CASE(Xfb), {}}, - {CASE(DepthReplacing), {}}, - {CASE(DepthGreater), {}}, - {CASE(DepthLess), {}}, - {CASE(DepthUnchanged), {}}, - {CASE(LocalSize), {64,1,2}}, - {CASE(LocalSizeHint), {8,2,4}}, - {CASE(InputPoints), {}}, - {CASE(InputLines), {}}, - {CASE(InputLinesAdjacency), {}}, - {CASE(InputTriangles), {}}, - {CASE(InputTrianglesAdjacency), {}}, - {CASE(InputQuads), {}}, - {CASE(InputIsolines), {}}, - {CASE(OutputVertices), {21}}, - {CASE(OutputPoints), {}}, - {CASE(OutputLineStrip), {}}, - {CASE(OutputTriangleStrip), {}}, - {CASE(VecTypeHint), {96}}, - {CASE(ContractionOff), {}}, - {CASE(IndependentForwardProgress), {}}, - })); +INSTANTIATE_TEST_CASE_P( + TextToBinaryExecutionMode, OpExecutionModeTest, + ::testing::ValuesIn(std::vector>{ + // The operand literal values are arbitrarily chosen, + // but there are the right number of them. + {CASE(Invocations), {101}}, + {CASE(SpacingEqual), {}}, + {CASE(SpacingFractionalEven), {}}, + {CASE(SpacingFractionalOdd), {}}, + {CASE(VertexOrderCw), {}}, + {CASE(VertexOrderCcw), {}}, + {CASE(PixelCenterInteger), {}}, + {CASE(OriginUpperLeft), {}}, + {CASE(OriginLowerLeft), {}}, + {CASE(EarlyFragmentTests), {}}, + {CASE(PointMode), {}}, + {CASE(Xfb), {}}, + {CASE(DepthReplacing), {}}, + {CASE(DepthGreater), {}}, + {CASE(DepthLess), {}}, + {CASE(DepthUnchanged), {}}, + {CASE(LocalSize), {64, 1, 2}}, + {CASE(LocalSizeHint), {8, 2, 4}}, + {CASE(InputPoints), {}}, + {CASE(InputLines), {}}, + {CASE(InputLinesAdjacency), {}}, + {CASE(InputTriangles), {}}, + {CASE(InputTrianglesAdjacency), {}}, + {CASE(InputQuads), {}}, + {CASE(InputIsolines), {}}, + {CASE(OutputVertices), {21}}, + {CASE(OutputPoints), {}}, + {CASE(OutputLineStrip), {}}, + {CASE(OutputTriangleStrip), {}}, + {CASE(VecTypeHint), {96}}, + {CASE(ContractionOff), {}}, + {CASE(IndependentForwardProgress), {}}, + })); #undef CASE -// clang-format on // Test OpCapability -- 2.7.4