Use generalized EnumCase in AccessQualifier assembly tests

This is in preparation for coming tests that will also
use the templated EnumCase instead of making their
own structs.

Also reformat AccessQualifier test.
This commit is contained in:
David Neto 2015-09-16 15:29:02 -04:00
parent ba569fb1aa
commit f7ee0ca5da

View File

@ -37,16 +37,17 @@ namespace {
using spvtest::MakeInstruction; using spvtest::MakeInstruction;
using ::testing::Eq; using ::testing::Eq;
// Test OpTypePipe // An example case for an enumerated value.
template <typename E>
// An example case for OpTypePipe struct EnumCase {
struct TypePipeCase { const E value;
spv::AccessQualifier value; const std::string name;
std::string name;
}; };
using OpTypePipeTest = // Test OpTypePipe
test_fixture::TextToBinaryTestBase<::testing::TestWithParam<TypePipeCase>>;
using OpTypePipeTest = test_fixture::TextToBinaryTestBase<
::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
TEST_P(OpTypePipeTest, AnyAccessQualifier) { TEST_P(OpTypePipeTest, AnyAccessQualifier) {
// TODO(dneto): In Rev31 and later, pipes are opaque, and so the %2, which // TODO(dneto): In Rev31 and later, pipes are opaque, and so the %2, which
@ -58,12 +59,13 @@ TEST_P(OpTypePipeTest, AnyAccessQualifier) {
// clang-format off // clang-format off
#define CASE(NAME) {spv::AccessQualifier##NAME, #NAME} #define CASE(NAME) {spv::AccessQualifier##NAME, #NAME}
INSTANTIATE_TEST_CASE_P(TextToBinaryTypePipe, OpTypePipeTest, INSTANTIATE_TEST_CASE_P(
::testing::ValuesIn(std::vector<TypePipeCase>{ TextToBinaryTypePipe, OpTypePipeTest,
CASE(ReadOnly), ::testing::ValuesIn(std::vector<EnumCase<spv::AccessQualifier>>{
CASE(WriteOnly), CASE(ReadOnly),
CASE(ReadWrite), CASE(WriteOnly),
})); CASE(ReadWrite),
}));
#undef CASE #undef CASE
// clang-format on // clang-format on