From 63b007d34f3e213154df82954588bfbc3a5367d1 Mon Sep 17 00:00:00 2001
From: dan sinclair <dsinclair@chromium.org>
Date: Wed, 26 Aug 2020 20:02:26 +0000
Subject: [PATCH] [hlsl-writer] Move test helper to a template.

This CL updates TestHelper to be a templated class and converts the test
suites into using statements based off that template.

Bug: tint:7
Change-Id: I747434e7c6a8ecae353df448f06153e982dcec44
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27500
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
---
 BUILD.gn                                      |  1 -
 src/CMakeLists.txt                            |  1 -
 .../hlsl/generator_impl_alias_type_test.cc    |  3 +-
 .../generator_impl_array_accessor_test.cc     |  3 +-
 src/writer/hlsl/generator_impl_as_test.cc     |  2 +-
 src/writer/hlsl/generator_impl_assign_test.cc |  2 +-
 src/writer/hlsl/generator_impl_binary_test.cc |  3 +-
 src/writer/hlsl/generator_impl_block_test.cc  |  2 +-
 src/writer/hlsl/generator_impl_break_test.cc  |  2 +-
 src/writer/hlsl/generator_impl_call_test.cc   |  2 +-
 src/writer/hlsl/generator_impl_case_test.cc   |  2 +-
 src/writer/hlsl/generator_impl_cast_test.cc   |  2 +-
 .../hlsl/generator_impl_constructor_test.cc   |  3 +-
 .../hlsl/generator_impl_continue_test.cc      |  3 +-
 .../hlsl/generator_impl_discard_test.cc       |  3 +-
 .../hlsl/generator_impl_entry_point_test.cc   |  3 +-
 .../hlsl/generator_impl_function_test.cc      |  3 +-
 .../hlsl/generator_impl_identifier_test.cc    |  3 +-
 src/writer/hlsl/generator_impl_if_test.cc     |  2 +-
 src/writer/hlsl/generator_impl_import_test.cc | 37 ++++++++-----------
 .../hlsl/generator_impl_intrinsic_test.cc     |  6 +--
 src/writer/hlsl/generator_impl_loop_test.cc   |  2 +-
 .../generator_impl_member_accessor_test.cc    |  3 +-
 .../generator_impl_module_constant_test.cc    |  3 +-
 src/writer/hlsl/generator_impl_return_test.cc |  2 +-
 src/writer/hlsl/generator_impl_switch_test.cc |  2 +-
 src/writer/hlsl/generator_impl_test.cc        |  7 ++--
 src/writer/hlsl/generator_impl_type_test.cc   |  2 +-
 .../hlsl/generator_impl_unary_op_test.cc      |  3 +-
 ...rator_impl_variable_decl_statement_test.cc |  3 +-
 src/writer/hlsl/test_helper.cc                | 27 --------------
 src/writer/hlsl/test_helper.h                 |  8 ++--
 32 files changed, 50 insertions(+), 100 deletions(-)
 delete mode 100644 src/writer/hlsl/test_helper.cc

diff --git a/BUILD.gn b/BUILD.gn
index ca2f5e5c19..52c9e50969 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1088,7 +1088,6 @@ source_set("tint_unittests_hlsl_writer_src") {
     "src/writer/hlsl/generator_impl_unary_op_test.cc",
     "src/writer/hlsl/generator_impl_variable_decl_statement_test.cc",
     "src/writer/hlsl/namer_test.cc",
-    "src/writer/hlsl/test_helper.cc",
     "src/writer/hlsl/test_helper.h",
   ]
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1451fb9c30..99ea14abc8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -599,7 +599,6 @@ if (${TINT_BUILD_HLSL_WRITER})
     writer/hlsl/generator_impl_unary_op_test.cc
     writer/hlsl/generator_impl_variable_decl_statement_test.cc
     writer/hlsl/namer_test.cc
-    writer/hlsl/test_helper.cc
     writer/hlsl/test_helper.h
   )
 endif()
diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc
index c68de9f679..703ac3b12b 100644
--- a/src/writer/hlsl/generator_impl_alias_type_test.cc
+++ b/src/writer/hlsl/generator_impl_alias_type_test.cc
@@ -27,8 +27,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_AliasType : public TestHelper,
-                                        public testing::Test {};
+using HlslGeneratorImplTest_AliasType = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_F32) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc
index ce7371dc08..0462efe38f 100644
--- a/src/writer/hlsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc
@@ -27,8 +27,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Expression : public TestHelper,
-                                         public testing::Test {};
+using HlslGeneratorImplTest_Expression = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
   ast::type::I32Type i32;
diff --git a/src/writer/hlsl/generator_impl_as_test.cc b/src/writer/hlsl/generator_impl_as_test.cc
index 710b57e725..7eb334d972 100644
--- a/src/writer/hlsl/generator_impl_as_test.cc
+++ b/src/writer/hlsl/generator_impl_as_test.cc
@@ -27,7 +27,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_As : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_As = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_As, EmitExpression_As_Float) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_assign_test.cc b/src/writer/hlsl/generator_impl_assign_test.cc
index 5781d97ace..c366717d7f 100644
--- a/src/writer/hlsl/generator_impl_assign_test.cc
+++ b/src/writer/hlsl/generator_impl_assign_test.cc
@@ -25,7 +25,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Assign : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Assign = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) {
   auto lhs = std::make_unique<ast::IdentifierExpression>("lhs");
diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc
index 717148abd6..2da3ad922c 100644
--- a/src/writer/hlsl/generator_impl_binary_test.cc
+++ b/src/writer/hlsl/generator_impl_binary_test.cc
@@ -33,8 +33,7 @@ inline std::ostream& operator<<(std::ostream& out, BinaryData data) {
   return out;
 }
 
-class HlslBinaryTest : public TestHelper,
-                       public testing::TestWithParam<BinaryData> {};
+using HlslBinaryTest = TestHelperBase<testing::TestWithParam<BinaryData>>;
 TEST_P(HlslBinaryTest, Emit) {
   auto params = GetParam();
 
diff --git a/src/writer/hlsl/generator_impl_block_test.cc b/src/writer/hlsl/generator_impl_block_test.cc
index 1d44592967..fd309e7aed 100644
--- a/src/writer/hlsl/generator_impl_block_test.cc
+++ b/src/writer/hlsl/generator_impl_block_test.cc
@@ -23,7 +23,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Block : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Block = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Block, Emit_Block) {
   ast::BlockStatement b;
diff --git a/src/writer/hlsl/generator_impl_break_test.cc b/src/writer/hlsl/generator_impl_break_test.cc
index eafd1889d8..7185ca91d6 100644
--- a/src/writer/hlsl/generator_impl_break_test.cc
+++ b/src/writer/hlsl/generator_impl_break_test.cc
@@ -24,7 +24,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Break : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Break = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Break, Emit_Break) {
   ast::BreakStatement b;
diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc
index 3405d1b80d..cbff0a8404 100644
--- a/src/writer/hlsl/generator_impl_call_test.cc
+++ b/src/writer/hlsl/generator_impl_call_test.cc
@@ -27,7 +27,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Call : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Call = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
   ast::type::VoidType void_type;
diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc
index 05d06c393c..c0330b94da 100644
--- a/src/writer/hlsl/generator_impl_case_test.cc
+++ b/src/writer/hlsl/generator_impl_case_test.cc
@@ -28,7 +28,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Case : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Case = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
   ast::type::I32Type i32;
diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc
index 1e782b3dd5..723f374f2a 100644
--- a/src/writer/hlsl/generator_impl_cast_test.cc
+++ b/src/writer/hlsl/generator_impl_cast_test.cc
@@ -26,7 +26,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Cast : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Cast = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc
index f9b2b2bfe9..6e3ef5e77c 100644
--- a/src/writer/hlsl/generator_impl_constructor_test.cc
+++ b/src/writer/hlsl/generator_impl_constructor_test.cc
@@ -33,8 +33,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Constructor : public TestHelper,
-                                          public testing::Test {};
+using HlslGeneratorImplTest_Constructor = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
   ast::type::BoolType bool_type;
diff --git a/src/writer/hlsl/generator_impl_continue_test.cc b/src/writer/hlsl/generator_impl_continue_test.cc
index 97b4ae09bb..170b7f7899 100644
--- a/src/writer/hlsl/generator_impl_continue_test.cc
+++ b/src/writer/hlsl/generator_impl_continue_test.cc
@@ -24,8 +24,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Continue : public TestHelper,
-                                       public testing::Test {};
+using HlslGeneratorImplTest_Continue = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
   ast::ContinueStatement c;
diff --git a/src/writer/hlsl/generator_impl_discard_test.cc b/src/writer/hlsl/generator_impl_discard_test.cc
index bbd4383e5d..8bf84fd3ef 100644
--- a/src/writer/hlsl/generator_impl_discard_test.cc
+++ b/src/writer/hlsl/generator_impl_discard_test.cc
@@ -21,8 +21,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Discard : public TestHelper,
-                                      public testing::Test {};
+using HlslGeneratorImplTest_Discard = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) {
   ast::DiscardStatement stmt;
diff --git a/src/writer/hlsl/generator_impl_entry_point_test.cc b/src/writer/hlsl/generator_impl_entry_point_test.cc
index 189c2abe3a..ad99c2e381 100644
--- a/src/writer/hlsl/generator_impl_entry_point_test.cc
+++ b/src/writer/hlsl/generator_impl_entry_point_test.cc
@@ -34,8 +34,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_EntryPoint : public TestHelper,
-                                         public testing::Test {};
+using HlslGeneratorImplTest_EntryPoint = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_EntryPoint, EmitEntryPointData_Vertex_Input) {
   // [[location 0]] var<in> foo : f32;
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index d79394b365..1546ddb3b9 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -48,8 +48,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Function : public TestHelper,
-                                       public testing::Test {};
+using HlslGeneratorImplTest_Function = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
   ast::type::VoidType void_type;
diff --git a/src/writer/hlsl/generator_impl_identifier_test.cc b/src/writer/hlsl/generator_impl_identifier_test.cc
index cdd99e77cd..58b5ed3ab6 100644
--- a/src/writer/hlsl/generator_impl_identifier_test.cc
+++ b/src/writer/hlsl/generator_impl_identifier_test.cc
@@ -21,8 +21,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Identifier : public TestHelper,
-                                         public testing::Test {};
+using HlslGeneratorImplTest_Identifier = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Identifier, DISABLED_EmitExpression_Identifier) {
   ast::IdentifierExpression i(std::vector<std::string>{"std", "glsl"});
diff --git a/src/writer/hlsl/generator_impl_if_test.cc b/src/writer/hlsl/generator_impl_if_test.cc
index cfdc393faa..df2a7d6734 100644
--- a/src/writer/hlsl/generator_impl_if_test.cc
+++ b/src/writer/hlsl/generator_impl_if_test.cc
@@ -24,7 +24,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_If : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_If = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_If, Emit_If) {
   auto cond = std::make_unique<ast::IdentifierExpression>("cond");
diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc
index a6c5631b8d..b97859d5c7 100644
--- a/src/writer/hlsl/generator_impl_import_test.cc
+++ b/src/writer/hlsl/generator_impl_import_test.cc
@@ -36,7 +36,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Import : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Import = TestHelper;
 
 struct HlslImportData {
   const char* name;
@@ -47,9 +47,8 @@ inline std::ostream& operator<<(std::ostream& out, HlslImportData data) {
   return out;
 }
 
-class HlslImportData_SingleParamTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_SingleParamTest =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
   auto param = GetParam();
 
@@ -113,9 +112,8 @@ TEST_F(HlslGeneratorImplTest_Import, DISABLED_HlslImportData_ATanh) {
   FAIL();
 }
 
-class HlslImportData_SingleIntParamTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_SingleIntParamTest =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
   auto param = GetParam();
 
@@ -140,9 +138,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
                          testing::Values(HlslImportData{"sabs", "abs"},
                                          HlslImportData{"ssign", "sign"}));
 
-class HlslImportData_DualParamTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_DualParamTest =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_DualParamTest, FloatScalar) {
   auto param = GetParam();
 
@@ -177,9 +174,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
                                          HlslImportData{"reflect", "reflect"},
                                          HlslImportData{"step", "step"}));
 
-class HlslImportData_DualParam_VectorTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_DualParam_VectorTest =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) {
   auto param = GetParam();
 
@@ -224,9 +220,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
                          HlslImportData_DualParam_VectorTest,
                          testing::Values(HlslImportData{"cross", "cross"}));
 
-class HlslImportData_DualParam_Int_Test
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_DualParam_Int_Test =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
   auto param = GetParam();
 
@@ -255,9 +250,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
                                          HlslImportData{"umax", "max"},
                                          HlslImportData{"umin", "min"}));
 
-class HlslImportData_TripleParamTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_TripleParamTest =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_TripleParamTest, FloatScalar) {
   auto param = GetParam();
 
@@ -295,9 +289,8 @@ TEST_F(HlslGeneratorImplTest_Import, DISABLED_HlslImportData_FMix) {
   FAIL();
 }
 
-class HlslImportData_TripleParam_Int_Test
-    : public TestHelper,
-      public testing::TestWithParam<HlslImportData> {};
+using HlslImportData_TripleParam_Int_Test =
+    TestHelperBase<testing::TestWithParam<HlslImportData>>;
 TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
   auto param = GetParam();
 
diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc
index 845628e853..f862ba7c9b 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc
@@ -26,8 +26,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Intrinsic : public TestHelper,
-                                        public testing::Test {};
+using HlslGeneratorImplTest_Intrinsic = TestHelper;
 
 struct IntrinsicData {
   const char* name;
@@ -37,8 +36,7 @@ inline std::ostream& operator<<(std::ostream& out, IntrinsicData data) {
   out << data.name;
   return out;
 }
-class HlslIntrinsicTest : public TestHelper,
-                          public testing::TestWithParam<IntrinsicData> {};
+using HlslIntrinsicTest = TestHelperBase<testing::TestWithParam<IntrinsicData>>;
 TEST_P(HlslIntrinsicTest, Emit) {
   auto param = GetParam();
   EXPECT_EQ(gen().generate_intrinsic_name(param.name), param.hlsl_name);
diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc
index 8a92b1c8d8..54d600ef9a 100644
--- a/src/writer/hlsl/generator_impl_loop_test.cc
+++ b/src/writer/hlsl/generator_impl_loop_test.cc
@@ -31,7 +31,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Loop : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Loop = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) {
   auto body = std::make_unique<ast::BlockStatement>();
diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc
index 8eec27ad8a..ccfe26a009 100644
--- a/src/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -43,8 +43,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_MemberAccessor : public TestHelper,
-                                             public testing::Test {};
+using HlslGeneratorImplTest_MemberAccessor = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc
index d787c2317c..abad8ea211 100644
--- a/src/writer/hlsl/generator_impl_module_constant_test.cc
+++ b/src/writer/hlsl/generator_impl_module_constant_test.cc
@@ -29,8 +29,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_ModuleConstant : public TestHelper,
-                                             public testing::Test {};
+using HlslGeneratorImplTest_ModuleConstant = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_return_test.cc b/src/writer/hlsl/generator_impl_return_test.cc
index 2662bd2257..d3b785aaea 100644
--- a/src/writer/hlsl/generator_impl_return_test.cc
+++ b/src/writer/hlsl/generator_impl_return_test.cc
@@ -25,7 +25,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Return : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Return = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Return, Emit_Return) {
   ast::ReturnStatement r;
diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc
index 3b0b5bf4e6..c8e7771c09 100644
--- a/src/writer/hlsl/generator_impl_switch_test.cc
+++ b/src/writer/hlsl/generator_impl_switch_test.cc
@@ -28,7 +28,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Switch : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Switch = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
   auto def = std::make_unique<ast::CaseStatement>();
diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc
index 5ddbeb01b0..22fa5d7f35 100644
--- a/src/writer/hlsl/generator_impl_test.cc
+++ b/src/writer/hlsl/generator_impl_test.cc
@@ -26,7 +26,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest = TestHelper;
 
 TEST_F(HlslGeneratorImplTest, DISABLED_Generate) {
   ast::type::VoidType void_type;
@@ -71,9 +71,8 @@ inline std::ostream& operator<<(std::ostream& out, HlslBuiltinData data) {
   out << data.builtin;
   return out;
 }
-class HlslBuiltinConversionTest
-    : public TestHelper,
-      public testing::TestWithParam<HlslBuiltinData> {};
+using HlslBuiltinConversionTest =
+    TestHelperBase<testing::TestWithParam<HlslBuiltinData>>;
 TEST_P(HlslBuiltinConversionTest, Emit) {
   auto params = GetParam();
   EXPECT_EQ(gen().builtin_to_attribute(params.builtin),
diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc
index 96c464bdc4..4a5b76dbaa 100644
--- a/src/writer/hlsl/generator_impl_type_test.cc
+++ b/src/writer/hlsl/generator_impl_type_test.cc
@@ -35,7 +35,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_Type : public TestHelper, public testing::Test {};
+using HlslGeneratorImplTest_Type = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/generator_impl_unary_op_test.cc b/src/writer/hlsl/generator_impl_unary_op_test.cc
index ae769429f4..6e97786813 100644
--- a/src/writer/hlsl/generator_impl_unary_op_test.cc
+++ b/src/writer/hlsl/generator_impl_unary_op_test.cc
@@ -33,8 +33,7 @@ inline std::ostream& operator<<(std::ostream& out, UnaryOpData data) {
   out << data.op;
   return out;
 }
-class HlslUnaryOpTest : public TestHelper,
-                        public testing::TestWithParam<UnaryOpData> {};
+using HlslUnaryOpTest = TestHelperBase<testing::TestWithParam<UnaryOpData>>;
 TEST_P(HlslUnaryOpTest, Emit) {
   auto params = GetParam();
 
diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
index bef692f880..f18e46694d 100644
--- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
@@ -30,8 +30,7 @@ namespace writer {
 namespace hlsl {
 namespace {
 
-class HlslGeneratorImplTest_VariableDecl : public TestHelper,
-                                           public testing::Test {};
+using HlslGeneratorImplTest_VariableDecl = TestHelper;
 
 TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
   ast::type::F32Type f32;
diff --git a/src/writer/hlsl/test_helper.cc b/src/writer/hlsl/test_helper.cc
deleted file mode 100644
index 7e5fc6fe02..0000000000
--- a/src/writer/hlsl/test_helper.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2020 The Tint Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "src/writer/hlsl/test_helper.h"
-
-namespace tint {
-namespace writer {
-namespace hlsl {
-
-TestHelper::TestHelper() : td_(&ctx_, &mod_), impl_(&mod_) {}
-
-TestHelper::~TestHelper() = default;
-
-}  // namespace hlsl
-}  // namespace writer
-}  // namespace tint
diff --git a/src/writer/hlsl/test_helper.h b/src/writer/hlsl/test_helper.h
index a8eceed7d4..68fa0e3b2a 100644
--- a/src/writer/hlsl/test_helper.h
+++ b/src/writer/hlsl/test_helper.h
@@ -28,10 +28,11 @@ namespace writer {
 namespace hlsl {
 
 /// Helper class for testing
-class TestHelper {
+template <typename T>
+class TestHelperBase : public T {
  public:
-  TestHelper();
-  ~TestHelper();
+  TestHelperBase() : td_(&ctx_, &mod_), impl_(&mod_) {}
+  ~TestHelperBase() = default;
 
   /// @returns the generator implementation
   GeneratorImpl& gen() { return impl_; }
@@ -55,6 +56,7 @@ class TestHelper {
   GeneratorImpl impl_;
   std::ostringstream out_;
 };
+using TestHelper = TestHelperBase<testing::Test>;
 
 }  // namespace hlsl
 }  // namespace writer