ast: Have all tests derive from new TestHelper

It doesn't actually do anything (yet), but will hold the context and
a helper for constructing AST nodes.

Bug: tint:322
Change-Id: Ic7ba92bf39abf64ff2ac51d81c8a6338f5eff608
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2020-11-13 21:58:28 +00:00 committed by Commit Bot service account
parent 6f58546193
commit 10d5c6a6b6
49 changed files with 132 additions and 92 deletions

View File

@ -769,6 +769,7 @@ source_set("tint_unittests_core_src") {
"src/ast/struct_member_test.cc", "src/ast/struct_member_test.cc",
"src/ast/struct_test.cc", "src/ast/struct_test.cc",
"src/ast/switch_statement_test.cc", "src/ast/switch_statement_test.cc",
"src/ast/test_helper.h",
"src/ast/type/access_control_type_test.cc", "src/ast/type/access_control_type_test.cc",
"src/ast/type/alias_type_test.cc", "src/ast/type/alias_type_test.cc",
"src/ast/type/array_type_test.cc", "src/ast/type/array_type_test.cc",

View File

@ -379,6 +379,7 @@ set(TINT_TEST_SRCS
ast/struct_member_offset_decoration_test.cc ast/struct_member_offset_decoration_test.cc
ast/struct_test.cc ast/struct_test.cc
ast/switch_statement_test.cc ast/switch_statement_test.cc
ast/test_helper.h
ast/type/access_control_type_test.cc ast/type/access_control_type_test.cc
ast/type/alias_type_test.cc ast/type/alias_type_test.cc
ast/type/array_type_test.cc ast/type/array_type_test.cc

View File

@ -14,14 +14,14 @@
#include "src/ast/array_accessor_expression.h" #include "src/ast/array_accessor_expression.h"
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ArrayAccessorExpressionTest = testing::Test; using ArrayAccessorExpressionTest = TestHelper;
TEST_F(ArrayAccessorExpressionTest, Create) { TEST_F(ArrayAccessorExpressionTest, Create) {
auto ary = std::make_unique<IdentifierExpression>("ary"); auto ary = std::make_unique<IdentifierExpression>("ary");

View File

@ -14,14 +14,14 @@
#include "src/ast/assignment_statement.h" #include "src/ast/assignment_statement.h"
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using AssignmentStatementTest = testing::Test; using AssignmentStatementTest = TestHelper;
TEST_F(AssignmentStatementTest, Creation) { TEST_F(AssignmentStatementTest, Creation) {
auto lhs = std::make_unique<ast::IdentifierExpression>("lhs"); auto lhs = std::make_unique<ast::IdentifierExpression>("lhs");

View File

@ -16,14 +16,14 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BinaryExpressionTest = testing::Test; using BinaryExpressionTest = TestHelper;
TEST_F(BinaryExpressionTest, Creation) { TEST_F(BinaryExpressionTest, Creation) {
auto lhs = std::make_unique<IdentifierExpression>("lhs"); auto lhs = std::make_unique<IdentifierExpression>("lhs");

View File

@ -14,13 +14,13 @@
#include "src/ast/binding_decoration.h" #include "src/ast/binding_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BindingDecorationTest = testing::Test; using BindingDecorationTest = TestHelper;
TEST_F(BindingDecorationTest, Creation) { TEST_F(BindingDecorationTest, Creation) {
BindingDecoration d{2, Source{}}; BindingDecoration d{2, Source{}};

View File

@ -14,15 +14,15 @@
#include "src/ast/bitcast_expression.h" #include "src/ast/bitcast_expression.h"
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BitcastExpressionTest = testing::Test; using BitcastExpressionTest = TestHelper;
TEST_F(BitcastExpressionTest, Create) { TEST_F(BitcastExpressionTest, Create) {
type::F32Type f32; type::F32Type f32;

View File

@ -17,15 +17,15 @@
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BlockStatementTest = testing::Test; using BlockStatementTest = TestHelper;
TEST_F(BlockStatementTest, Creation) { TEST_F(BlockStatementTest, Creation) {
auto d = std::make_unique<DiscardStatement>(); auto d = std::make_unique<DiscardStatement>();

View File

@ -14,14 +14,14 @@
#include "src/ast/bool_literal.h" #include "src/ast/bool_literal.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/bool_type.h" #include "src/ast/type/bool_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BoolLiteralTest = testing::Test; using BoolLiteralTest = TestHelper;
TEST_F(BoolLiteralTest, True) { TEST_F(BoolLiteralTest, True) {
ast::type::BoolType bool_type; ast::type::BoolType bool_type;

View File

@ -14,13 +14,13 @@
#include "src/ast/break_statement.h" #include "src/ast/break_statement.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BreakStatementTest = testing::Test; using BreakStatementTest = TestHelper;
TEST_F(BreakStatementTest, Creation_WithSource) { TEST_F(BreakStatementTest, Creation_WithSource) {
BreakStatement stmt(Source{Source::Location{20, 2}}); BreakStatement stmt(Source{Source::Location{20, 2}});

View File

@ -14,13 +14,13 @@
#include "src/ast/builtin_decoration.h" #include "src/ast/builtin_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using BuiltinDecorationTest = testing::Test; using BuiltinDecorationTest = TestHelper;
TEST_F(BuiltinDecorationTest, Creation) { TEST_F(BuiltinDecorationTest, Creation) {
BuiltinDecoration d{Builtin::kFragDepth, Source{}}; BuiltinDecoration d{Builtin::kFragDepth, Source{}};

View File

@ -14,14 +14,14 @@
#include "src/ast/call_expression.h" #include "src/ast/call_expression.h"
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using CallExpressionTest = testing::Test; using CallExpressionTest = TestHelper;
TEST_F(CallExpressionTest, Creation) { TEST_F(CallExpressionTest, Creation) {
auto func = std::make_unique<IdentifierExpression>("func"); auto func = std::make_unique<IdentifierExpression>("func");

View File

@ -14,15 +14,15 @@
#include "src/ast/call_statement.h" #include "src/ast/call_statement.h"
#include "gtest/gtest.h"
#include "src/ast/call_expression.h" #include "src/ast/call_expression.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using CallStatementTest = testing::Test; using CallStatementTest = TestHelper;
TEST_F(CallStatementTest, Creation) { TEST_F(CallStatementTest, Creation) {
auto expr = std::make_unique<ast::CallExpression>( auto expr = std::make_unique<ast::CallExpression>(

View File

@ -14,10 +14,10 @@
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "gtest/gtest.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "src/ast/sint_literal.h" #include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
#include "src/ast/type/u32_type.h" #include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
@ -26,7 +26,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using CaseStatementTest = testing::Test; using CaseStatementTest = TestHelper;
TEST_F(CaseStatementTest, Creation_i32) { TEST_F(CaseStatementTest, Creation_i32) {
ast::type::I32Type i32; ast::type::I32Type i32;

View File

@ -14,13 +14,13 @@
#include "src/ast/constant_id_decoration.h" #include "src/ast/constant_id_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ConstantIdDecorationTest = testing::Test; using ConstantIdDecorationTest = TestHelper;
TEST_F(ConstantIdDecorationTest, Creation) { TEST_F(ConstantIdDecorationTest, Creation) {
ConstantIdDecoration d{12, Source{}}; ConstantIdDecoration d{12, Source{}};

View File

@ -14,13 +14,13 @@
#include "src/ast/continue_statement.h" #include "src/ast/continue_statement.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ContinueStatementTest = testing::Test; using ContinueStatementTest = TestHelper;
TEST_F(ContinueStatementTest, Creation_WithSource) { TEST_F(ContinueStatementTest, Creation_WithSource) {
ContinueStatement stmt(Source{Source::Location{20, 2}}); ContinueStatement stmt(Source{Source::Location{20, 2}});

View File

@ -14,13 +14,13 @@
#include "src/ast/decorated_variable.h" #include "src/ast/decorated_variable.h"
#include "gtest/gtest.h"
#include "src/ast/binding_decoration.h" #include "src/ast/binding_decoration.h"
#include "src/ast/builtin_decoration.h" #include "src/ast/builtin_decoration.h"
#include "src/ast/constant_id_decoration.h" #include "src/ast/constant_id_decoration.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/location_decoration.h" #include "src/ast/location_decoration.h"
#include "src/ast/set_decoration.h" #include "src/ast/set_decoration.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
@ -30,7 +30,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using DecoratedVariableTest = testing::Test; using DecoratedVariableTest = TestHelper;
TEST_F(DecoratedVariableTest, Creation) { TEST_F(DecoratedVariableTest, Creation) {
type::I32Type t; type::I32Type t;

View File

@ -17,16 +17,15 @@
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include "gtest/gtest.h"
#include "src/ast/array_decoration.h" #include "src/ast/array_decoration.h"
#include "src/ast/constant_id_decoration.h" #include "src/ast/constant_id_decoration.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using DecorationTest = testing::Test; using DecorationTest = TestHelper;
TEST_F(DecorationTest, AsCorrectType) { TEST_F(DecorationTest, AsCorrectType) {
auto* decoration = new ConstantIdDecoration(1, Source{}); auto* decoration = new ConstantIdDecoration(1, Source{});

View File

@ -16,13 +16,13 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using DiscardStatementTest = testing::Test; using DiscardStatementTest = TestHelper;
TEST_F(DiscardStatementTest, Creation) { TEST_F(DiscardStatementTest, Creation) {
DiscardStatement stmt; DiscardStatement stmt;

View File

@ -14,18 +14,18 @@
#include "src/ast/else_statement.h" #include "src/ast/else_statement.h"
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h" #include "src/ast/bool_literal.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "src/ast/scalar_constructor_expression.h" #include "src/ast/scalar_constructor_expression.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/bool_type.h" #include "src/ast/type/bool_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ElseStatementTest = testing::Test; using ElseStatementTest = TestHelper;
TEST_F(ElseStatementTest, Creation) { TEST_F(ElseStatementTest, Creation) {
ast::type::BoolType bool_type; ast::type::BoolType bool_type;

View File

@ -14,7 +14,7 @@
#include "src/ast/expression.h" #include "src/ast/expression.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/alias_type.h" #include "src/ast/type/alias_type.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
@ -30,7 +30,7 @@ class Expr : public Expression {
void to_str(std::ostream&, size_t) const override {} void to_str(std::ostream&, size_t) const override {}
}; };
using ExpressionTest = testing::Test; using ExpressionTest = TestHelper;
TEST_F(ExpressionTest, set_result_type) { TEST_F(ExpressionTest, set_result_type) {
type::I32Type i32; type::I32Type i32;

View File

@ -14,13 +14,13 @@
#include "src/ast/fallthrough_statement.h" #include "src/ast/fallthrough_statement.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using FallthroughStatementTest = testing::Test; using FallthroughStatementTest = TestHelper;
TEST_F(FallthroughStatementTest, Creation) { TEST_F(FallthroughStatementTest, Creation) {
FallthroughStatement stmt; FallthroughStatement stmt;

View File

@ -14,14 +14,14 @@
#include "src/ast/float_literal.h" #include "src/ast/float_literal.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using FloatLiteralTest = testing::Test; using FloatLiteralTest = TestHelper;
TEST_F(FloatLiteralTest, Value) { TEST_F(FloatLiteralTest, Value) {
ast::type::F32Type f32; ast::type::F32Type f32;

View File

@ -14,12 +14,12 @@
#include "src/ast/function.h" #include "src/ast/function.h"
#include "gtest/gtest.h"
#include "src/ast/builtin_decoration.h" #include "src/ast/builtin_decoration.h"
#include "src/ast/decorated_variable.h" #include "src/ast/decorated_variable.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/location_decoration.h" #include "src/ast/location_decoration.h"
#include "src/ast/pipeline_stage.h" #include "src/ast/pipeline_stage.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
#include "src/ast/type/void_type.h" #include "src/ast/type/void_type.h"
@ -30,7 +30,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using FunctionTest = testing::Test; using FunctionTest = TestHelper;
TEST_F(FunctionTest, Creation) { TEST_F(FunctionTest, Creation) {
type::VoidType void_type; type::VoidType void_type;

View File

@ -14,13 +14,13 @@
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using IdentifierExpressionTest = testing::Test; using IdentifierExpressionTest = TestHelper;
TEST_F(IdentifierExpressionTest, Creation) { TEST_F(IdentifierExpressionTest, Creation) {
IdentifierExpression i("ident"); IdentifierExpression i("ident");

View File

@ -14,15 +14,15 @@
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "gtest/gtest.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using IfStatementTest = testing::Test; using IfStatementTest = TestHelper;
TEST_F(IfStatementTest, Creation) { TEST_F(IfStatementTest, Creation) {
auto cond = std::make_unique<IdentifierExpression>("cond"); auto cond = std::make_unique<IdentifierExpression>("cond");

View File

@ -14,8 +14,8 @@
#include "src/ast/int_literal.h" #include "src/ast/int_literal.h"
#include "gtest/gtest.h"
#include "src/ast/sint_literal.h" #include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
#include "src/ast/type/u32_type.h" #include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
@ -24,7 +24,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using IntLiteralTest = testing::Test; using IntLiteralTest = TestHelper;
TEST_F(IntLiteralTest, Sint_IsInt) { TEST_F(IntLiteralTest, Sint_IsInt) {
ast::type::I32Type i32; ast::type::I32Type i32;

View File

@ -16,13 +16,13 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using LocationDecorationTest = testing::Test; using LocationDecorationTest = TestHelper;
TEST_F(LocationDecorationTest, Creation) { TEST_F(LocationDecorationTest, Creation) {
LocationDecoration d{2, Source{}}; LocationDecoration d{2, Source{}};

View File

@ -17,15 +17,15 @@
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/discard_statement.h" #include "src/ast/discard_statement.h"
#include "src/ast/if_statement.h" #include "src/ast/if_statement.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using LoopStatementTest = testing::Test; using LoopStatementTest = TestHelper;
TEST_F(LoopStatementTest, Creation) { TEST_F(LoopStatementTest, Creation) {
auto body = std::make_unique<BlockStatement>(); auto body = std::make_unique<BlockStatement>();

View File

@ -16,14 +16,14 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using MemberAccessorExpressionTest = testing::Test; using MemberAccessorExpressionTest = TestHelper;
TEST_F(MemberAccessorExpressionTest, Creation) { TEST_F(MemberAccessorExpressionTest, Creation) {
auto str = std::make_unique<IdentifierExpression>("structure"); auto str = std::make_unique<IdentifierExpression>("structure");

View File

@ -19,6 +19,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "src/ast/function.h" #include "src/ast/function.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/alias_type.h" #include "src/ast/type/alias_type.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/type/struct_type.h" #include "src/ast/type/struct_type.h"
@ -28,7 +29,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ModuleTest = testing::Test; using ModuleTest = TestHelper;
TEST_F(ModuleTest, Creation) { TEST_F(ModuleTest, Creation) {
Module m; Module m;

View File

@ -14,14 +14,14 @@
#include "src/ast/null_literal.h" #include "src/ast/null_literal.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using NullLiteralTest = testing::Test; using NullLiteralTest = TestHelper;
TEST_F(NullLiteralTest, Is) { TEST_F(NullLiteralTest, Is) {
ast::type::I32Type i32; ast::type::I32Type i32;

View File

@ -16,14 +16,14 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ReturnStatementTest = testing::Test; using ReturnStatementTest = TestHelper;
TEST_F(ReturnStatementTest, Creation) { TEST_F(ReturnStatementTest, Creation) {
auto expr = std::make_unique<IdentifierExpression>("expr"); auto expr = std::make_unique<IdentifierExpression>("expr");

View File

@ -14,15 +14,15 @@
#include "src/ast/scalar_constructor_expression.h" #include "src/ast/scalar_constructor_expression.h"
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h" #include "src/ast/bool_literal.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/bool_type.h" #include "src/ast/type/bool_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using ScalarConstructorExpressionTest = testing::Test; using ScalarConstructorExpressionTest = TestHelper;
TEST_F(ScalarConstructorExpressionTest, Creation) { TEST_F(ScalarConstructorExpressionTest, Creation) {
ast::type::BoolType bool_type; ast::type::BoolType bool_type;

View File

@ -14,13 +14,13 @@
#include "src/ast/set_decoration.h" #include "src/ast/set_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using SetDecorationTest = testing::Test; using SetDecorationTest = TestHelper;
TEST_F(SetDecorationTest, Creation) { TEST_F(SetDecorationTest, Creation) {
SetDecoration d{2, Source{}}; SetDecoration d{2, Source{}};

View File

@ -14,7 +14,7 @@
#include "src/ast/sint_literal.h" #include "src/ast/sint_literal.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
#include "src/ast/type/u32_type.h" #include "src/ast/type/u32_type.h"
@ -22,7 +22,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using SintLiteralTest = testing::Test; using SintLiteralTest = TestHelper;
TEST_F(SintLiteralTest, Value) { TEST_F(SintLiteralTest, Value) {
ast::type::I32Type i32; ast::type::I32Type i32;

View File

@ -16,13 +16,13 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using StageDecorationTest = testing::Test; using StageDecorationTest = TestHelper;
TEST_F(StageDecorationTest, Creation_1param) { TEST_F(StageDecorationTest, Creation_1param) {
StageDecoration d{ast::PipelineStage::kFragment, Source{}}; StageDecoration d{ast::PipelineStage::kFragment, Source{}};

View File

@ -14,13 +14,13 @@
#include "src/ast/stride_decoration.h" #include "src/ast/stride_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using StrideDecorationTest = testing::Test; using StrideDecorationTest = TestHelper;
TEST_F(StrideDecorationTest, Creation) { TEST_F(StrideDecorationTest, Creation) {
StrideDecoration d{2, Source{}}; StrideDecoration d{2, Source{}};

View File

@ -14,13 +14,13 @@
#include "src/ast/struct_member_offset_decoration.h" #include "src/ast/struct_member_offset_decoration.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using StructMemberOffsetDecorationTest = testing::Test; using StructMemberOffsetDecorationTest = TestHelper;
TEST_F(StructMemberOffsetDecorationTest, Creation) { TEST_F(StructMemberOffsetDecorationTest, Creation) {
StructMemberOffsetDecoration d{2, Source{}}; StructMemberOffsetDecoration d{2, Source{}};

View File

@ -17,15 +17,15 @@
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include "gtest/gtest.h"
#include "src/ast/struct_member_offset_decoration.h" #include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using StructMemberTest = testing::Test; using StructMemberTest = TestHelper;
TEST_F(StructMemberTest, Creation) { TEST_F(StructMemberTest, Creation) {
type::I32Type i32; type::I32Type i32;

View File

@ -18,16 +18,16 @@
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include "gtest/gtest.h"
#include "src/ast/struct_block_decoration.h" #include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member.h" #include "src/ast/struct_member.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using StructTest = testing::Test; using StructTest = TestHelper;
TEST_F(StructTest, Creation) { TEST_F(StructTest, Creation) {
type::I32Type i32; type::I32Type i32;

View File

@ -16,17 +16,17 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/case_statement.h" #include "src/ast/case_statement.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/sint_literal.h" #include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using SwitchStatementTest = testing::Test; using SwitchStatementTest = TestHelper;
TEST_F(SwitchStatementTest, Creation) { TEST_F(SwitchStatementTest, Creation) {
ast::type::I32Type i32; ast::type::I32Type i32;

38
src/ast/test_helper.h Normal file
View File

@ -0,0 +1,38 @@
// 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.
#ifndef SRC_AST_TEST_HELPER_H_
#define SRC_AST_TEST_HELPER_H_
#include "gtest/gtest.h"
namespace tint {
namespace ast {
/// Helper class for testing
template <typename BASE>
class TestHelperBase : public BASE {
public:
TestHelperBase() {}
~TestHelperBase() = default;
};
using TestHelper = TestHelperBase<testing::Test>;
template <typename T>
using TestParamHelper = TestHelperBase<testing::TestWithParam<T>>;
} // namespace ast
} // namespace tint
#endif // SRC_AST_TEST_HELPER_H_

View File

@ -17,9 +17,9 @@
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/constructor_expression.h" #include "src/ast/constructor_expression.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/type/vector_type.h" #include "src/ast/type/vector_type.h"
@ -27,7 +27,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using TypeConstructorExpressionTest = testing::Test; using TypeConstructorExpressionTest = TestHelper;
TEST_F(TypeConstructorExpressionTest, Creation) { TEST_F(TypeConstructorExpressionTest, Creation) {
type::F32Type f32; type::F32Type f32;

View File

@ -14,14 +14,14 @@
#include "src/ast/uint_literal.h" #include "src/ast/uint_literal.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/u32_type.h" #include "src/ast/type/u32_type.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using UintLiteralTest = testing::Test; using UintLiteralTest = TestHelper;
TEST_F(UintLiteralTest, Value) { TEST_F(UintLiteralTest, Value) {
ast::type::U32Type u32; ast::type::U32Type u32;

View File

@ -16,14 +16,14 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using UnaryOpExpressionTest = testing::Test; using UnaryOpExpressionTest = TestHelper;
TEST_F(UnaryOpExpressionTest, Creation) { TEST_F(UnaryOpExpressionTest, Creation) {
auto ident = std::make_unique<IdentifierExpression>("ident"); auto ident = std::make_unique<IdentifierExpression>("ident");

View File

@ -14,7 +14,7 @@
#include "src/ast/variable_decl_statement.h" #include "src/ast/variable_decl_statement.h"
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/variable.h" #include "src/ast/variable.h"
@ -22,7 +22,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using VariableDeclStatementTest = testing::Test; using VariableDeclStatementTest = TestHelper;
TEST_F(VariableDeclStatementTest, Creation) { TEST_F(VariableDeclStatementTest, Creation) {
type::F32Type f32; type::F32Type f32;

View File

@ -14,8 +14,8 @@
#include "src/ast/variable.h" #include "src/ast/variable.h"
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h" #include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
#include "src/ast/type/f32_type.h" #include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h" #include "src/ast/type/i32_type.h"
@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using VariableTest = testing::Test; using VariableTest = TestHelper;
TEST_F(VariableTest, Creation) { TEST_F(VariableTest, Creation) {
type::I32Type t; type::I32Type t;

View File

@ -16,13 +16,13 @@
#include <sstream> #include <sstream>
#include "gtest/gtest.h" #include "src/ast/test_helper.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
namespace { namespace {
using WorkgroupDecorationTest = testing::Test; using WorkgroupDecorationTest = TestHelper;
TEST_F(WorkgroupDecorationTest, Creation_1param) { TEST_F(WorkgroupDecorationTest, Creation_1param) {
WorkgroupDecoration d{2, Source{}}; WorkgroupDecoration d{2, Source{}};