mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
tint: Add missing tests / benchmarks
For enums generated by intrinsic.def. Change-Id: I1072248b31e2a365a558736f903d25f6e6184962 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112381 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
f1f6e6fbea
commit
f62aec2dc8
@ -1016,6 +1016,7 @@ if (tint_build_unittests) {
|
|||||||
|
|
||||||
tint_unittests_source_set("tint_unittests_ast_src") {
|
tint_unittests_source_set("tint_unittests_ast_src") {
|
||||||
sources = [
|
sources = [
|
||||||
|
"ast/access_test.cc",
|
||||||
"ast/address_space_test.cc",
|
"ast/address_space_test.cc",
|
||||||
"ast/alias_test.cc",
|
"ast/alias_test.cc",
|
||||||
"ast/array_test.cc",
|
"ast/array_test.cc",
|
||||||
|
@ -535,11 +535,11 @@ list(APPEND TINT_LIB_SRCS
|
|||||||
writer/writer.h
|
writer/writer.h
|
||||||
)
|
)
|
||||||
|
|
||||||
tint_generated(ast/access)
|
tint_generated(ast/access BENCH TEST)
|
||||||
tint_generated(ast/address_space BENCH TEST)
|
tint_generated(ast/address_space BENCH TEST)
|
||||||
tint_generated(ast/builtin_value BENCH TEST)
|
tint_generated(ast/builtin_value BENCH TEST)
|
||||||
tint_generated(ast/extension BENCH TEST)
|
tint_generated(ast/extension BENCH TEST)
|
||||||
tint_generated(ast/interpolate_attribute)
|
tint_generated(ast/interpolate_attribute BENCH TEST)
|
||||||
tint_generated(ast/texel_format BENCH TEST)
|
tint_generated(ast/texel_format BENCH TEST)
|
||||||
tint_generated(resolver/init_conv_intrinsic)
|
tint_generated(resolver/init_conv_intrinsic)
|
||||||
tint_generated(sem/builtin_type)
|
tint_generated(sem/builtin_type)
|
||||||
@ -809,7 +809,6 @@ if(TINT_BUILD_TESTS)
|
|||||||
ast/increment_decrement_statement_test.cc
|
ast/increment_decrement_statement_test.cc
|
||||||
ast/index_accessor_expression_test.cc
|
ast/index_accessor_expression_test.cc
|
||||||
ast/int_literal_expression_test.cc
|
ast/int_literal_expression_test.cc
|
||||||
ast/interpolate_attribute_test.cc
|
|
||||||
ast/invariant_attribute_test.cc
|
ast/invariant_attribute_test.cc
|
||||||
ast/location_attribute_test.cc
|
ast/location_attribute_test.cc
|
||||||
ast/loop_statement_test.cc
|
ast/loop_statement_test.cc
|
||||||
|
51
src/tint/ast/access_bench.cc
Normal file
51
src/tint/ast/access_bench.cc
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/src/cmd/gen
|
||||||
|
// using the template:
|
||||||
|
// src/tint/ast/access_bench.cc.tmpl
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "src/tint/ast/access.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void AccessParser(::benchmark::State& state) {
|
||||||
|
std::array kStrings{
|
||||||
|
"ccad", "3", "rVad", "read", "1ead",
|
||||||
|
"rqaJ", "rlla77", "reqqdppriHHe", "rv_wcit", "reabGwrte",
|
||||||
|
"read_write", "read_vriite", "re8d_wriWWe", "Meadxxrite", "wggte",
|
||||||
|
"VtX", "writ3", "write", "writE", "TTrPte",
|
||||||
|
"wxxidd",
|
||||||
|
};
|
||||||
|
for (auto _ : state) {
|
||||||
|
for (auto& str : kStrings) {
|
||||||
|
auto result = ParseAccess(str);
|
||||||
|
benchmark::DoNotOptimize(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK(AccessParser);
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
29
src/tint/ast/access_bench.cc.tmpl
Normal file
29
src/tint/ast/access_bench.cc.tmpl
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{{- /*
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Template file for use with tools/src/cmd/gen to generate access_bench.cc
|
||||||
|
|
||||||
|
To update the generated file, run:
|
||||||
|
./tools/run gen
|
||||||
|
|
||||||
|
See:
|
||||||
|
* tools/src/cmd/gen for structures used by this template
|
||||||
|
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||||
|
{{- $enum := (Sem.Enum "access") -}}
|
||||||
|
|
||||||
|
#include "src/tint/ast/access.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
{{ Eval "BenchmarkParseEnum" $enum }}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
82
src/tint/ast/access_test.cc
Normal file
82
src/tint/ast/access_test.cc
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/src/cmd/gen
|
||||||
|
// using the template:
|
||||||
|
// src/tint/ast/access_test.cc.tmpl
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "src/tint/ast/access.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "src/tint/ast/test_helper.h"
|
||||||
|
#include "src/tint/utils/string.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
namespace parse_print_tests {
|
||||||
|
|
||||||
|
struct Case {
|
||||||
|
const char* string;
|
||||||
|
Access value;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, Case c) {
|
||||||
|
return out << "'" << std::string(c.string) << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr Case kValidCases[] = {
|
||||||
|
{"read", Access::kRead},
|
||||||
|
{"read_write", Access::kReadWrite},
|
||||||
|
{"write", Access::kWrite},
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr Case kInvalidCases[] = {
|
||||||
|
{"ccad", Access::kUndefined}, {"3", Access::kUndefined},
|
||||||
|
{"rVad", Access::kUndefined}, {"read1write", Access::kUndefined},
|
||||||
|
{"reaJqqrite", Access::kUndefined}, {"rea7ll_write", Access::kUndefined},
|
||||||
|
{"wrqHtpp", Access::kUndefined}, {"ve", Access::kUndefined},
|
||||||
|
{"Grbe", Access::kUndefined},
|
||||||
|
};
|
||||||
|
|
||||||
|
using AccessParseTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(AccessParseTest, Parse) {
|
||||||
|
const char* string = GetParam().string;
|
||||||
|
Access expect = GetParam().value;
|
||||||
|
EXPECT_EQ(expect, ParseAccess(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases, AccessParseTest, testing::ValuesIn(kValidCases));
|
||||||
|
INSTANTIATE_TEST_SUITE_P(InvalidCases, AccessParseTest, testing::ValuesIn(kInvalidCases));
|
||||||
|
|
||||||
|
using AccessPrintTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(AccessPrintTest, Print) {
|
||||||
|
Access value = GetParam().value;
|
||||||
|
const char* expect = GetParam().string;
|
||||||
|
EXPECT_EQ(expect, utils::ToString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases, AccessPrintTest, testing::ValuesIn(kValidCases));
|
||||||
|
|
||||||
|
} // namespace parse_print_tests
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
30
src/tint/ast/access_test.cc.tmpl
Normal file
30
src/tint/ast/access_test.cc.tmpl
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{{- /*
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Template file for use with tools/src/cmd/gen to generate access_test.cc
|
||||||
|
|
||||||
|
To update the generated file, run:
|
||||||
|
./tools/run gen
|
||||||
|
|
||||||
|
See:
|
||||||
|
* tools/src/cmd/gen for structures used by this template
|
||||||
|
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||||
|
{{- $enum := (Sem.Enum "access") -}}
|
||||||
|
|
||||||
|
#include "src/tint/ast/access.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "src/tint/ast/test_helper.h"
|
||||||
|
#include "src/tint/utils/string.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
{{ Eval "TestParsePrintEnum" $enum}}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
67
src/tint/ast/interpolate_attribute_bench.cc
Normal file
67
src/tint/ast/interpolate_attribute_bench.cc
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/src/cmd/gen
|
||||||
|
// using the template:
|
||||||
|
// src/tint/ast/interpolate_attribute_bench.cc.tmpl
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void InterpolationTypeParser(::benchmark::State& state) {
|
||||||
|
std::array kStrings{
|
||||||
|
"ccat", "3", "fVat", "flat", "1lat",
|
||||||
|
"fqaJ", "flla77", "lippeHHr", "cin", "lbGea",
|
||||||
|
"linear", "liveaii", "liWWe8r", "xxiner", "perggpctXve",
|
||||||
|
"ueVspXtve", "3erspective", "perspective", "perspectivE", "peTTspectiPe",
|
||||||
|
"pxxdrspectve",
|
||||||
|
};
|
||||||
|
for (auto _ : state) {
|
||||||
|
for (auto& str : kStrings) {
|
||||||
|
auto result = ParseInterpolationType(str);
|
||||||
|
benchmark::DoNotOptimize(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK(InterpolationTypeParser);
|
||||||
|
|
||||||
|
void InterpolationSamplingParser(::benchmark::State& state) {
|
||||||
|
std::array kStrings{
|
||||||
|
"44enter", "cSSVVter", "centRr", "center", "ent9r", "cente", "VentORr",
|
||||||
|
"cenyroi", "77errtrllnid", "04entroid", "centroid", "enooid", "centzzd", "ceiippr1i",
|
||||||
|
"saXXple", "55IImpnn99", "aHHrrmplSS", "sample", "kkle", "jagRR", "smbe",
|
||||||
|
};
|
||||||
|
for (auto _ : state) {
|
||||||
|
for (auto& str : kStrings) {
|
||||||
|
auto result = ParseInterpolationSampling(str);
|
||||||
|
benchmark::DoNotOptimize(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BENCHMARK(InterpolationSamplingParser);
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
27
src/tint/ast/interpolate_attribute_bench.cc.tmpl
Normal file
27
src/tint/ast/interpolate_attribute_bench.cc.tmpl
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{{- /*
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Template file for use with tools/src/cmd/gen to generate interpolate_attribute_bench.cc
|
||||||
|
|
||||||
|
See:
|
||||||
|
* tools/src/cmd/gen for structures used by this template
|
||||||
|
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||||
|
|
||||||
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "benchmark/benchmark.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
{{ Eval "BenchmarkParseEnum" (Sem.Enum "interpolation_type")}}
|
||||||
|
|
||||||
|
{{ Eval "BenchmarkParseEnum" (Sem.Enum "interpolation_sampling")}}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
@ -12,9 +12,20 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/src/cmd/gen
|
||||||
|
// using the template:
|
||||||
|
// src/tint/ast/interpolate_attribute_test.cc.tmpl
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "src/tint/ast/interpolate_attribute.h"
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "src/tint/ast/test_helper.h"
|
#include "src/tint/ast/test_helper.h"
|
||||||
|
#include "src/tint/utils/string.h"
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
namespace {
|
namespace {
|
||||||
@ -28,5 +39,117 @@ TEST_F(InterpolateAttributeTest, Creation) {
|
|||||||
EXPECT_EQ(InterpolationSampling::kCenter, d->sampling);
|
EXPECT_EQ(InterpolationSampling::kCenter, d->sampling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace interpolation_type_tests {
|
||||||
|
|
||||||
|
namespace parse_print_tests {
|
||||||
|
|
||||||
|
struct Case {
|
||||||
|
const char* string;
|
||||||
|
InterpolationType value;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, Case c) {
|
||||||
|
return out << "'" << std::string(c.string) << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr Case kValidCases[] = {
|
||||||
|
{"flat", InterpolationType::kFlat},
|
||||||
|
{"linear", InterpolationType::kLinear},
|
||||||
|
{"perspective", InterpolationType::kPerspective},
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr Case kInvalidCases[] = {
|
||||||
|
{"ccat", InterpolationType::kUndefined}, {"3", InterpolationType::kUndefined},
|
||||||
|
{"fVat", InterpolationType::kUndefined}, {"1inear", InterpolationType::kUndefined},
|
||||||
|
{"lnqqar", InterpolationType::kUndefined}, {"linell77", InterpolationType::kUndefined},
|
||||||
|
{"perppHqective", InterpolationType::kUndefined}, {"cespctve", InterpolationType::kUndefined},
|
||||||
|
{"ebGpective", InterpolationType::kUndefined},
|
||||||
|
};
|
||||||
|
|
||||||
|
using InterpolationTypeParseTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(InterpolationTypeParseTest, Parse) {
|
||||||
|
const char* string = GetParam().string;
|
||||||
|
InterpolationType expect = GetParam().value;
|
||||||
|
EXPECT_EQ(expect, ParseInterpolationType(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases, InterpolationTypeParseTest, testing::ValuesIn(kValidCases));
|
||||||
|
INSTANTIATE_TEST_SUITE_P(InvalidCases,
|
||||||
|
InterpolationTypeParseTest,
|
||||||
|
testing::ValuesIn(kInvalidCases));
|
||||||
|
|
||||||
|
using InterpolationTypePrintTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(InterpolationTypePrintTest, Print) {
|
||||||
|
InterpolationType value = GetParam().value;
|
||||||
|
const char* expect = GetParam().string;
|
||||||
|
EXPECT_EQ(expect, utils::ToString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases, InterpolationTypePrintTest, testing::ValuesIn(kValidCases));
|
||||||
|
|
||||||
|
} // namespace parse_print_tests
|
||||||
|
|
||||||
|
} // namespace interpolation_type_tests
|
||||||
|
|
||||||
|
namespace interpolation_sampling_tests {
|
||||||
|
|
||||||
|
namespace parse_print_tests {
|
||||||
|
|
||||||
|
struct Case {
|
||||||
|
const char* string;
|
||||||
|
InterpolationSampling value;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, Case c) {
|
||||||
|
return out << "'" << std::string(c.string) << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr Case kValidCases[] = {
|
||||||
|
{"center", InterpolationSampling::kCenter},
|
||||||
|
{"centroid", InterpolationSampling::kCentroid},
|
||||||
|
{"sample", InterpolationSampling::kSample},
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr Case kInvalidCases[] = {
|
||||||
|
{"cevteii", InterpolationSampling::kUndefined}, {"ceWWt8r", InterpolationSampling::kUndefined},
|
||||||
|
{"xxentr", InterpolationSampling::kUndefined}, {"ceXggrid", InterpolationSampling::kUndefined},
|
||||||
|
{"ceXriu", InterpolationSampling::kUndefined}, {"centr3id", InterpolationSampling::kUndefined},
|
||||||
|
{"sEmple", InterpolationSampling::kUndefined}, {"amTTlPP", InterpolationSampling::kUndefined},
|
||||||
|
{"ddamxxl", InterpolationSampling::kUndefined},
|
||||||
|
};
|
||||||
|
|
||||||
|
using InterpolationSamplingParseTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(InterpolationSamplingParseTest, Parse) {
|
||||||
|
const char* string = GetParam().string;
|
||||||
|
InterpolationSampling expect = GetParam().value;
|
||||||
|
EXPECT_EQ(expect, ParseInterpolationSampling(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases,
|
||||||
|
InterpolationSamplingParseTest,
|
||||||
|
testing::ValuesIn(kValidCases));
|
||||||
|
INSTANTIATE_TEST_SUITE_P(InvalidCases,
|
||||||
|
InterpolationSamplingParseTest,
|
||||||
|
testing::ValuesIn(kInvalidCases));
|
||||||
|
|
||||||
|
using InterpolationSamplingPrintTest = testing::TestWithParam<Case>;
|
||||||
|
|
||||||
|
TEST_P(InterpolationSamplingPrintTest, Print) {
|
||||||
|
InterpolationSampling value = GetParam().value;
|
||||||
|
const char* expect = GetParam().string;
|
||||||
|
EXPECT_EQ(expect, utils::ToString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(ValidCases,
|
||||||
|
InterpolationSamplingPrintTest,
|
||||||
|
testing::ValuesIn(kValidCases));
|
||||||
|
|
||||||
|
} // namespace parse_print_tests
|
||||||
|
|
||||||
|
} // namespace interpolation_sampling_tests
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
|
45
src/tint/ast/interpolate_attribute_test.cc.tmpl
Normal file
45
src/tint/ast/interpolate_attribute_test.cc.tmpl
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{{- /*
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
Template file for use with tools/src/cmd/gen to generate interpolate_attribute_test.cc
|
||||||
|
|
||||||
|
See:
|
||||||
|
* tools/src/cmd/gen for structures used by this template
|
||||||
|
* https://golang.org/pkg/text/template/ for documentation on the template syntax
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
|
||||||
|
|
||||||
|
#include "src/tint/ast/interpolate_attribute.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "src/tint/ast/test_helper.h"
|
||||||
|
#include "src/tint/utils/string.h"
|
||||||
|
|
||||||
|
namespace tint::ast {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using InterpolateAttributeTest = TestHelper;
|
||||||
|
|
||||||
|
TEST_F(InterpolateAttributeTest, Creation) {
|
||||||
|
auto* d =
|
||||||
|
create<InterpolateAttribute>(InterpolationType::kLinear, InterpolationSampling::kCenter);
|
||||||
|
EXPECT_EQ(InterpolationType::kLinear, d->type);
|
||||||
|
EXPECT_EQ(InterpolationSampling::kCenter, d->sampling);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace interpolation_type_tests {
|
||||||
|
|
||||||
|
{{ Eval "TestParsePrintEnum" (Sem.Enum "interpolation_type")}}
|
||||||
|
|
||||||
|
} // namespace interpolation_type_tests
|
||||||
|
|
||||||
|
namespace interpolation_sampling_tests {
|
||||||
|
|
||||||
|
{{ Eval "TestParsePrintEnum" (Sem.Enum "interpolation_sampling")}}
|
||||||
|
|
||||||
|
} // namespace interpolation_sampling_tests
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace tint::ast
|
Loading…
x
Reference in New Issue
Block a user