[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>
This commit is contained in:
parent
663be30b55
commit
63b007d34f
1
BUILD.gn
1
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_unary_op_test.cc",
|
||||||
"src/writer/hlsl/generator_impl_variable_decl_statement_test.cc",
|
"src/writer/hlsl/generator_impl_variable_decl_statement_test.cc",
|
||||||
"src/writer/hlsl/namer_test.cc",
|
"src/writer/hlsl/namer_test.cc",
|
||||||
"src/writer/hlsl/test_helper.cc",
|
|
||||||
"src/writer/hlsl/test_helper.h",
|
"src/writer/hlsl/test_helper.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -599,7 +599,6 @@ if (${TINT_BUILD_HLSL_WRITER})
|
||||||
writer/hlsl/generator_impl_unary_op_test.cc
|
writer/hlsl/generator_impl_unary_op_test.cc
|
||||||
writer/hlsl/generator_impl_variable_decl_statement_test.cc
|
writer/hlsl/generator_impl_variable_decl_statement_test.cc
|
||||||
writer/hlsl/namer_test.cc
|
writer/hlsl/namer_test.cc
|
||||||
writer/hlsl/test_helper.cc
|
|
||||||
writer/hlsl/test_helper.h
|
writer/hlsl/test_helper.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -27,8 +27,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_AliasType : public TestHelper,
|
using HlslGeneratorImplTest_AliasType = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_F32) {
|
TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_F32) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -27,8 +27,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Expression : public TestHelper,
|
using HlslGeneratorImplTest_Expression = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
|
TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_As : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_As = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_As, EmitExpression_As_Float) {
|
TEST_F(HlslGeneratorImplTest_As, EmitExpression_As_Float) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Assign : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Assign = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) {
|
TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) {
|
||||||
auto lhs = std::make_unique<ast::IdentifierExpression>("lhs");
|
auto lhs = std::make_unique<ast::IdentifierExpression>("lhs");
|
||||||
|
|
|
@ -33,8 +33,7 @@ inline std::ostream& operator<<(std::ostream& out, BinaryData data) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HlslBinaryTest : public TestHelper,
|
using HlslBinaryTest = TestHelperBase<testing::TestWithParam<BinaryData>>;
|
||||||
public testing::TestWithParam<BinaryData> {};
|
|
||||||
TEST_P(HlslBinaryTest, Emit) {
|
TEST_P(HlslBinaryTest, Emit) {
|
||||||
auto params = GetParam();
|
auto params = GetParam();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Block : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Block = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Block, Emit_Block) {
|
TEST_F(HlslGeneratorImplTest_Block, Emit_Block) {
|
||||||
ast::BlockStatement b;
|
ast::BlockStatement b;
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Break : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Break = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Break, Emit_Break) {
|
TEST_F(HlslGeneratorImplTest_Break, Emit_Break) {
|
||||||
ast::BreakStatement b;
|
ast::BreakStatement b;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Call : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Call = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
||||||
ast::type::VoidType void_type;
|
ast::type::VoidType void_type;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Case : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Case = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
|
TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Cast : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Cast = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
|
TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -33,8 +33,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Constructor : public TestHelper,
|
using HlslGeneratorImplTest_Constructor = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
|
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
|
||||||
ast::type::BoolType bool_type;
|
ast::type::BoolType bool_type;
|
||||||
|
|
|
@ -24,8 +24,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Continue : public TestHelper,
|
using HlslGeneratorImplTest_Continue = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
|
TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) {
|
||||||
ast::ContinueStatement c;
|
ast::ContinueStatement c;
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Discard : public TestHelper,
|
using HlslGeneratorImplTest_Discard = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) {
|
TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) {
|
||||||
ast::DiscardStatement stmt;
|
ast::DiscardStatement stmt;
|
||||||
|
|
|
@ -34,8 +34,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_EntryPoint : public TestHelper,
|
using HlslGeneratorImplTest_EntryPoint = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_EntryPoint, EmitEntryPointData_Vertex_Input) {
|
TEST_F(HlslGeneratorImplTest_EntryPoint, EmitEntryPointData_Vertex_Input) {
|
||||||
// [[location 0]] var<in> foo : f32;
|
// [[location 0]] var<in> foo : f32;
|
||||||
|
|
|
@ -48,8 +48,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Function : public TestHelper,
|
using HlslGeneratorImplTest_Function = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
|
TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
|
||||||
ast::type::VoidType void_type;
|
ast::type::VoidType void_type;
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Identifier : public TestHelper,
|
using HlslGeneratorImplTest_Identifier = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Identifier, DISABLED_EmitExpression_Identifier) {
|
TEST_F(HlslGeneratorImplTest_Identifier, DISABLED_EmitExpression_Identifier) {
|
||||||
ast::IdentifierExpression i(std::vector<std::string>{"std", "glsl"});
|
ast::IdentifierExpression i(std::vector<std::string>{"std", "glsl"});
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_If : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_If = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_If, Emit_If) {
|
TEST_F(HlslGeneratorImplTest_If, Emit_If) {
|
||||||
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
auto cond = std::make_unique<ast::IdentifierExpression>("cond");
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Import : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Import = TestHelper;
|
||||||
|
|
||||||
struct HlslImportData {
|
struct HlslImportData {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -47,9 +47,8 @@ inline std::ostream& operator<<(std::ostream& out, HlslImportData data) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
class HlslImportData_SingleParamTest
|
using HlslImportData_SingleParamTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
|
TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -113,9 +112,8 @@ TEST_F(HlslGeneratorImplTest_Import, DISABLED_HlslImportData_ATanh) {
|
||||||
FAIL();
|
FAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
class HlslImportData_SingleIntParamTest
|
using HlslImportData_SingleIntParamTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
|
TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -140,9 +138,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
|
||||||
testing::Values(HlslImportData{"sabs", "abs"},
|
testing::Values(HlslImportData{"sabs", "abs"},
|
||||||
HlslImportData{"ssign", "sign"}));
|
HlslImportData{"ssign", "sign"}));
|
||||||
|
|
||||||
class HlslImportData_DualParamTest
|
using HlslImportData_DualParamTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_DualParamTest, FloatScalar) {
|
TEST_P(HlslImportData_DualParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -177,9 +174,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
|
||||||
HlslImportData{"reflect", "reflect"},
|
HlslImportData{"reflect", "reflect"},
|
||||||
HlslImportData{"step", "step"}));
|
HlslImportData{"step", "step"}));
|
||||||
|
|
||||||
class HlslImportData_DualParam_VectorTest
|
using HlslImportData_DualParam_VectorTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) {
|
TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -224,9 +220,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
|
||||||
HlslImportData_DualParam_VectorTest,
|
HlslImportData_DualParam_VectorTest,
|
||||||
testing::Values(HlslImportData{"cross", "cross"}));
|
testing::Values(HlslImportData{"cross", "cross"}));
|
||||||
|
|
||||||
class HlslImportData_DualParam_Int_Test
|
using HlslImportData_DualParam_Int_Test =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
|
TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -255,9 +250,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
|
||||||
HlslImportData{"umax", "max"},
|
HlslImportData{"umax", "max"},
|
||||||
HlslImportData{"umin", "min"}));
|
HlslImportData{"umin", "min"}));
|
||||||
|
|
||||||
class HlslImportData_TripleParamTest
|
using HlslImportData_TripleParamTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_TripleParamTest, FloatScalar) {
|
TEST_P(HlslImportData_TripleParamTest, FloatScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
@ -295,9 +289,8 @@ TEST_F(HlslGeneratorImplTest_Import, DISABLED_HlslImportData_FMix) {
|
||||||
FAIL();
|
FAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
class HlslImportData_TripleParam_Int_Test
|
using HlslImportData_TripleParam_Int_Test =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslImportData>>;
|
||||||
public testing::TestWithParam<HlslImportData> {};
|
|
||||||
TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
|
TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Intrinsic : public TestHelper,
|
using HlslGeneratorImplTest_Intrinsic = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
struct IntrinsicData {
|
struct IntrinsicData {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -37,8 +36,7 @@ inline std::ostream& operator<<(std::ostream& out, IntrinsicData data) {
|
||||||
out << data.name;
|
out << data.name;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
class HlslIntrinsicTest : public TestHelper,
|
using HlslIntrinsicTest = TestHelperBase<testing::TestWithParam<IntrinsicData>>;
|
||||||
public testing::TestWithParam<IntrinsicData> {};
|
|
||||||
TEST_P(HlslIntrinsicTest, Emit) {
|
TEST_P(HlslIntrinsicTest, Emit) {
|
||||||
auto param = GetParam();
|
auto param = GetParam();
|
||||||
EXPECT_EQ(gen().generate_intrinsic_name(param.name), param.hlsl_name);
|
EXPECT_EQ(gen().generate_intrinsic_name(param.name), param.hlsl_name);
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Loop : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Loop = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) {
|
TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) {
|
||||||
auto body = std::make_unique<ast::BlockStatement>();
|
auto body = std::make_unique<ast::BlockStatement>();
|
||||||
|
|
|
@ -43,8 +43,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_MemberAccessor : public TestHelper,
|
using HlslGeneratorImplTest_MemberAccessor = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -29,8 +29,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_ModuleConstant : public TestHelper,
|
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Return : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Return = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Return, Emit_Return) {
|
TEST_F(HlslGeneratorImplTest_Return, Emit_Return) {
|
||||||
ast::ReturnStatement r;
|
ast::ReturnStatement r;
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Switch : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Switch = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
|
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
|
||||||
auto def = std::make_unique<ast::CaseStatement>();
|
auto def = std::make_unique<ast::CaseStatement>();
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest, DISABLED_Generate) {
|
TEST_F(HlslGeneratorImplTest, DISABLED_Generate) {
|
||||||
ast::type::VoidType void_type;
|
ast::type::VoidType void_type;
|
||||||
|
@ -71,9 +71,8 @@ inline std::ostream& operator<<(std::ostream& out, HlslBuiltinData data) {
|
||||||
out << data.builtin;
|
out << data.builtin;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
class HlslBuiltinConversionTest
|
using HlslBuiltinConversionTest =
|
||||||
: public TestHelper,
|
TestHelperBase<testing::TestWithParam<HlslBuiltinData>>;
|
||||||
public testing::TestWithParam<HlslBuiltinData> {};
|
|
||||||
TEST_P(HlslBuiltinConversionTest, Emit) {
|
TEST_P(HlslBuiltinConversionTest, Emit) {
|
||||||
auto params = GetParam();
|
auto params = GetParam();
|
||||||
EXPECT_EQ(gen().builtin_to_attribute(params.builtin),
|
EXPECT_EQ(gen().builtin_to_attribute(params.builtin),
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_Type : public TestHelper, public testing::Test {};
|
using HlslGeneratorImplTest_Type = TestHelper;
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
|
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -33,8 +33,7 @@ inline std::ostream& operator<<(std::ostream& out, UnaryOpData data) {
|
||||||
out << data.op;
|
out << data.op;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
class HlslUnaryOpTest : public TestHelper,
|
using HlslUnaryOpTest = TestHelperBase<testing::TestWithParam<UnaryOpData>>;
|
||||||
public testing::TestWithParam<UnaryOpData> {};
|
|
||||||
TEST_P(HlslUnaryOpTest, Emit) {
|
TEST_P(HlslUnaryOpTest, Emit) {
|
||||||
auto params = GetParam();
|
auto params = GetParam();
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class HlslGeneratorImplTest_VariableDecl : public TestHelper,
|
using HlslGeneratorImplTest_VariableDecl = TestHelper;
|
||||||
public testing::Test {};
|
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
|
@ -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
|
|
|
@ -28,10 +28,11 @@ namespace writer {
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
|
|
||||||
/// Helper class for testing
|
/// Helper class for testing
|
||||||
class TestHelper {
|
template <typename T>
|
||||||
|
class TestHelperBase : public T {
|
||||||
public:
|
public:
|
||||||
TestHelper();
|
TestHelperBase() : td_(&ctx_, &mod_), impl_(&mod_) {}
|
||||||
~TestHelper();
|
~TestHelperBase() = default;
|
||||||
|
|
||||||
/// @returns the generator implementation
|
/// @returns the generator implementation
|
||||||
GeneratorImpl& gen() { return impl_; }
|
GeneratorImpl& gen() { return impl_; }
|
||||||
|
@ -55,6 +56,7 @@ class TestHelper {
|
||||||
GeneratorImpl impl_;
|
GeneratorImpl impl_;
|
||||||
std::ostringstream out_;
|
std::ostringstream out_;
|
||||||
};
|
};
|
||||||
|
using TestHelper = TestHelperBase<testing::Test>;
|
||||||
|
|
||||||
} // namespace hlsl
|
} // namespace hlsl
|
||||||
} // namespace writer
|
} // namespace writer
|
||||||
|
|
Loading…
Reference in New Issue