Use generalized EnumCase in AccessQualifier assembly tests
authorDavid Neto <dneto@google.com>
Wed, 16 Sep 2015 19:29:02 +0000 (15:29 -0400)
committerDavid Neto <dneto@google.com>
Mon, 26 Oct 2015 16:55:33 +0000 (12:55 -0400)
This is in preparation for coming tests that will also
use the templated EnumCase instead of making their
own structs.

Also reformat AccessQualifier test.

test/TextToBinary.TypeDeclaration.cpp

index 89c2b7d..3525e3b 100644 (file)
@@ -37,16 +37,17 @@ namespace {
 using spvtest::MakeInstruction;
 using ::testing::Eq;
 
-// Test OpTypePipe
-
-// An example case for OpTypePipe
-struct TypePipeCase {
-  spv::AccessQualifier value;
-  std::string name;
+// An example case for an enumerated value.
+template <typename E>
+struct EnumCase {
+  const E value;
+  const std::string name;
 };
 
-using OpTypePipeTest =
-    test_fixture::TextToBinaryTestBase<::testing::TestWithParam<TypePipeCase>>;
+// Test OpTypePipe
+
+using OpTypePipeTest = test_fixture::TextToBinaryTestBase<
+    ::testing::TestWithParam<EnumCase<spv::AccessQualifier>>>;
 
 TEST_P(OpTypePipeTest, AnyAccessQualifier) {
   // 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
 #define CASE(NAME) {spv::AccessQualifier##NAME, #NAME}
-INSTANTIATE_TEST_CASE_P(TextToBinaryTypePipe, OpTypePipeTest,
-                        ::testing::ValuesIn(std::vector<TypePipeCase>{
-                            CASE(ReadOnly),
-                            CASE(WriteOnly),
-                            CASE(ReadWrite),
-                        }));
+INSTANTIATE_TEST_CASE_P(
+    TextToBinaryTypePipe, OpTypePipeTest,
+    ::testing::ValuesIn(std::vector<EnumCase<spv::AccessQualifier>>{
+        CASE(ReadOnly),
+        CASE(WriteOnly),
+        CASE(ReadWrite),
+    }));
 #undef CASE
 // clang-format on