tint/type: Rename ShortName to type::Builtin

These will include the builtin language types.

Bug: tint:1810
Change-Id: I695a9ee833e1035eb1d17913d709038ae4c561d8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118502
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2023-02-07 13:35:58 +00:00
committed by Dawn LUCI CQ
parent a5ea0a1450
commit ad73301856
21 changed files with 353 additions and 318 deletions

View File

@@ -15,175 +15,175 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/short_name.cc.tmpl
// src/tint/type/builtin.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/short_name.h"
#include "src/tint/type/builtin.h"
namespace tint::type {
/// ParseShortName parses a ShortName from a string.
/// ParseBuiltin parses a Builtin from a string.
/// @param str the string to parse
/// @returns the parsed enum, or ShortName::kUndefined if the string could not be parsed.
ShortName ParseShortName(std::string_view str) {
/// @returns the parsed enum, or Builtin::kUndefined if the string could not be parsed.
Builtin ParseBuiltin(std::string_view str) {
if (str == "mat2x2f") {
return ShortName::kMat2X2F;
return Builtin::kMat2X2F;
}
if (str == "mat2x2h") {
return ShortName::kMat2X2H;
return Builtin::kMat2X2H;
}
if (str == "mat2x3f") {
return ShortName::kMat2X3F;
return Builtin::kMat2X3F;
}
if (str == "mat2x3h") {
return ShortName::kMat2X3H;
return Builtin::kMat2X3H;
}
if (str == "mat2x4f") {
return ShortName::kMat2X4F;
return Builtin::kMat2X4F;
}
if (str == "mat2x4h") {
return ShortName::kMat2X4H;
return Builtin::kMat2X4H;
}
if (str == "mat3x2f") {
return ShortName::kMat3X2F;
return Builtin::kMat3X2F;
}
if (str == "mat3x2h") {
return ShortName::kMat3X2H;
return Builtin::kMat3X2H;
}
if (str == "mat3x3f") {
return ShortName::kMat3X3F;
return Builtin::kMat3X3F;
}
if (str == "mat3x3h") {
return ShortName::kMat3X3H;
return Builtin::kMat3X3H;
}
if (str == "mat3x4f") {
return ShortName::kMat3X4F;
return Builtin::kMat3X4F;
}
if (str == "mat3x4h") {
return ShortName::kMat3X4H;
return Builtin::kMat3X4H;
}
if (str == "mat4x2f") {
return ShortName::kMat4X2F;
return Builtin::kMat4X2F;
}
if (str == "mat4x2h") {
return ShortName::kMat4X2H;
return Builtin::kMat4X2H;
}
if (str == "mat4x3f") {
return ShortName::kMat4X3F;
return Builtin::kMat4X3F;
}
if (str == "mat4x3h") {
return ShortName::kMat4X3H;
return Builtin::kMat4X3H;
}
if (str == "mat4x4f") {
return ShortName::kMat4X4F;
return Builtin::kMat4X4F;
}
if (str == "mat4x4h") {
return ShortName::kMat4X4H;
return Builtin::kMat4X4H;
}
if (str == "vec2f") {
return ShortName::kVec2F;
return Builtin::kVec2F;
}
if (str == "vec2h") {
return ShortName::kVec2H;
return Builtin::kVec2H;
}
if (str == "vec2i") {
return ShortName::kVec2I;
return Builtin::kVec2I;
}
if (str == "vec2u") {
return ShortName::kVec2U;
return Builtin::kVec2U;
}
if (str == "vec3f") {
return ShortName::kVec3F;
return Builtin::kVec3F;
}
if (str == "vec3h") {
return ShortName::kVec3H;
return Builtin::kVec3H;
}
if (str == "vec3i") {
return ShortName::kVec3I;
return Builtin::kVec3I;
}
if (str == "vec3u") {
return ShortName::kVec3U;
return Builtin::kVec3U;
}
if (str == "vec4f") {
return ShortName::kVec4F;
return Builtin::kVec4F;
}
if (str == "vec4h") {
return ShortName::kVec4H;
return Builtin::kVec4H;
}
if (str == "vec4i") {
return ShortName::kVec4I;
return Builtin::kVec4I;
}
if (str == "vec4u") {
return ShortName::kVec4U;
return Builtin::kVec4U;
}
return ShortName::kUndefined;
return Builtin::kUndefined;
}
std::ostream& operator<<(std::ostream& out, ShortName value) {
std::ostream& operator<<(std::ostream& out, Builtin value) {
switch (value) {
case ShortName::kUndefined:
case Builtin::kUndefined:
return out << "undefined";
case ShortName::kMat2X2F:
case Builtin::kMat2X2F:
return out << "mat2x2f";
case ShortName::kMat2X2H:
case Builtin::kMat2X2H:
return out << "mat2x2h";
case ShortName::kMat2X3F:
case Builtin::kMat2X3F:
return out << "mat2x3f";
case ShortName::kMat2X3H:
case Builtin::kMat2X3H:
return out << "mat2x3h";
case ShortName::kMat2X4F:
case Builtin::kMat2X4F:
return out << "mat2x4f";
case ShortName::kMat2X4H:
case Builtin::kMat2X4H:
return out << "mat2x4h";
case ShortName::kMat3X2F:
case Builtin::kMat3X2F:
return out << "mat3x2f";
case ShortName::kMat3X2H:
case Builtin::kMat3X2H:
return out << "mat3x2h";
case ShortName::kMat3X3F:
case Builtin::kMat3X3F:
return out << "mat3x3f";
case ShortName::kMat3X3H:
case Builtin::kMat3X3H:
return out << "mat3x3h";
case ShortName::kMat3X4F:
case Builtin::kMat3X4F:
return out << "mat3x4f";
case ShortName::kMat3X4H:
case Builtin::kMat3X4H:
return out << "mat3x4h";
case ShortName::kMat4X2F:
case Builtin::kMat4X2F:
return out << "mat4x2f";
case ShortName::kMat4X2H:
case Builtin::kMat4X2H:
return out << "mat4x2h";
case ShortName::kMat4X3F:
case Builtin::kMat4X3F:
return out << "mat4x3f";
case ShortName::kMat4X3H:
case Builtin::kMat4X3H:
return out << "mat4x3h";
case ShortName::kMat4X4F:
case Builtin::kMat4X4F:
return out << "mat4x4f";
case ShortName::kMat4X4H:
case Builtin::kMat4X4H:
return out << "mat4x4h";
case ShortName::kVec2F:
case Builtin::kVec2F:
return out << "vec2f";
case ShortName::kVec2H:
case Builtin::kVec2H:
return out << "vec2h";
case ShortName::kVec2I:
case Builtin::kVec2I:
return out << "vec2i";
case ShortName::kVec2U:
case Builtin::kVec2U:
return out << "vec2u";
case ShortName::kVec3F:
case Builtin::kVec3F:
return out << "vec3f";
case ShortName::kVec3H:
case Builtin::kVec3H:
return out << "vec3h";
case ShortName::kVec3I:
case Builtin::kVec3I:
return out << "vec3i";
case ShortName::kVec3U:
case Builtin::kVec3U:
return out << "vec3u";
case ShortName::kVec4F:
case Builtin::kVec4F:
return out << "vec4f";
case ShortName::kVec4H:
case Builtin::kVec4H:
return out << "vec4h";
case ShortName::kVec4I:
case Builtin::kVec4I:
return out << "vec4i";
case ShortName::kVec4U:
case Builtin::kVec4U:
return out << "vec4u";
}
return out << "<unknown>";

View File

@@ -1,6 +1,6 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate short_name.cc
Template file for use with tools/src/cmd/gen to generate builtin.cc
To update the generated file, run:
./tools/run gen
@@ -12,9 +12,10 @@ See:
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "short_name") -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/short_name.h"
#include "src/tint/type/builtin.h"
namespace tint::type {

View File

@@ -15,20 +15,20 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/short_name.h.tmpl
// src/tint/type/builtin.h.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#ifndef SRC_TINT_TYPE_SHORT_NAME_H_
#define SRC_TINT_TYPE_SHORT_NAME_H_
#ifndef SRC_TINT_TYPE_BUILTIN_H_
#define SRC_TINT_TYPE_BUILTIN_H_
#include <ostream>
namespace tint::type {
/// An enumerator of builtin type aliases.
enum class ShortName {
/// An enumerator of builtin types.
enum class Builtin {
kUndefined,
kMat2X2F,
kMat2X2H,
@@ -63,16 +63,16 @@ enum class ShortName {
};
/// @param out the std::ostream to write to
/// @param value the ShortName
/// @param value the Builtin
/// @returns `out` so calls can be chained
std::ostream& operator<<(std::ostream& out, ShortName value);
std::ostream& operator<<(std::ostream& out, Builtin value);
/// ParseShortName parses a ShortName from a string.
/// ParseBuiltin parses a Builtin from a string.
/// @param str the string to parse
/// @returns the parsed enum, or ShortName::kUndefined if the string could not be parsed.
ShortName ParseShortName(std::string_view str);
/// @returns the parsed enum, or Builtin::kUndefined if the string could not be parsed.
Builtin ParseBuiltin(std::string_view str);
constexpr const char* kShortNameStrings[] = {
constexpr const char* kBuiltinStrings[] = {
"mat2x2f", "mat2x2h", "mat2x3f", "mat2x3h", "mat2x4f", "mat2x4h", "mat3x2f", "mat3x2h",
"mat3x3f", "mat3x3h", "mat3x4f", "mat3x4h", "mat4x2f", "mat4x2h", "mat4x3f", "mat4x3h",
"mat4x4f", "mat4x4h", "vec2f", "vec2h", "vec2i", "vec2u", "vec3f", "vec3h",
@@ -81,4 +81,4 @@ constexpr const char* kShortNameStrings[] = {
} // namespace tint::type
#endif // SRC_TINT_TYPE_SHORT_NAME_H_
#endif // SRC_TINT_TYPE_BUILTIN_H_

View File

@@ -1,6 +1,6 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate short_name.h
Template file for use with tools/src/cmd/gen to generate builtin.h
To update the generated file, run:
./tools/run gen
@@ -12,18 +12,19 @@ See:
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "short_name") -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#ifndef SRC_TINT_TYPE_SHORT_NAME_H_
#define SRC_TINT_TYPE_SHORT_NAME_H_
#ifndef SRC_TINT_TYPE_BUILTIN_H_
#define SRC_TINT_TYPE_BUILTIN_H_
#include <ostream>
namespace tint::type {
/// An enumerator of builtin type aliases.
/// An enumerator of builtin types.
{{ Eval "DeclareEnum" $enum}}
} // namespace tint::type
#endif // SRC_TINT_TYPE_SHORT_NAME_H_
#endif // SRC_TINT_TYPE_BUILTIN_H_

View File

@@ -15,12 +15,12 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/short_name_bench.cc.tmpl
// src/tint/type/builtin_bench.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/short_name.h"
#include "src/tint/type/builtin.h"
#include <array>
@@ -29,7 +29,7 @@
namespace tint::type {
namespace {
void ShortNameParser(::benchmark::State& state) {
void BuiltinParser(::benchmark::State& state) {
std::array kStrings{
"at2x2cc", "l23f", "matVx2f", "mat2x2f", "mat212f", "mqtJx2f",
"mat2x27ll", "ppqqt22HH", "macv", "bt2xGh", "mat2x2h", "mat2iivh",
@@ -69,13 +69,13 @@ void ShortNameParser(::benchmark::State& state) {
};
for (auto _ : state) {
for (auto& str : kStrings) {
auto result = ParseShortName(str);
auto result = ParseBuiltin(str);
benchmark::DoNotOptimize(result);
}
}
}
BENCHMARK(ShortNameParser);
BENCHMARK(BuiltinParser);
} // namespace
} // namespace tint::type

View File

@@ -1,6 +1,6 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate short_name_bench.cc
Template file for use with tools/src/cmd/gen to generate builtin_bench.cc
To update the generated file, run:
./tools/run gen
@@ -12,9 +12,10 @@ See:
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "short_name") -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/short_name.h"
#include "src/tint/type/builtin.h"
#include <array>

View File

@@ -0,0 +1,130 @@
// 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/type/builtin_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/builtin.h"
#include <string>
#include "gtest/gtest.h"
#include "src/tint/utils/string.h"
namespace tint::type {
namespace {
namespace parse_print_tests {
struct Case {
const char* string;
Builtin value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"mat2x2f", Builtin::kMat2X2F}, {"mat2x2h", Builtin::kMat2X2H}, {"mat2x3f", Builtin::kMat2X3F},
{"mat2x3h", Builtin::kMat2X3H}, {"mat2x4f", Builtin::kMat2X4F}, {"mat2x4h", Builtin::kMat2X4H},
{"mat3x2f", Builtin::kMat3X2F}, {"mat3x2h", Builtin::kMat3X2H}, {"mat3x3f", Builtin::kMat3X3F},
{"mat3x3h", Builtin::kMat3X3H}, {"mat3x4f", Builtin::kMat3X4F}, {"mat3x4h", Builtin::kMat3X4H},
{"mat4x2f", Builtin::kMat4X2F}, {"mat4x2h", Builtin::kMat4X2H}, {"mat4x3f", Builtin::kMat4X3F},
{"mat4x3h", Builtin::kMat4X3H}, {"mat4x4f", Builtin::kMat4X4F}, {"mat4x4h", Builtin::kMat4X4H},
{"vec2f", Builtin::kVec2F}, {"vec2h", Builtin::kVec2H}, {"vec2i", Builtin::kVec2I},
{"vec2u", Builtin::kVec2U}, {"vec3f", Builtin::kVec3F}, {"vec3h", Builtin::kVec3H},
{"vec3i", Builtin::kVec3I}, {"vec3u", Builtin::kVec3U}, {"vec4f", Builtin::kVec4F},
{"vec4h", Builtin::kVec4H}, {"vec4i", Builtin::kVec4I}, {"vec4u", Builtin::kVec4U},
};
static constexpr Case kInvalidCases[] = {
{"at2x2cc", Builtin::kUndefined}, {"l23f", Builtin::kUndefined},
{"matVx2f", Builtin::kUndefined}, {"mat212h", Builtin::kUndefined},
{"mqtJx2h", Builtin::kUndefined}, {"mat2x27ll", Builtin::kUndefined},
{"ppqqt23HH", Builtin::kUndefined}, {"macv", Builtin::kUndefined},
{"bt2xGf", Builtin::kUndefined}, {"mat2iivh", Builtin::kUndefined},
{"8WWt2x3h", Builtin::kUndefined}, {"mxx2x3h", Builtin::kUndefined},
{"mX2x4gg", Builtin::kUndefined}, {"a2xXf", Builtin::kUndefined},
{"mat234f", Builtin::kUndefined}, {"Eat2x4h", Builtin::kUndefined},
{"mPTT2x4h", Builtin::kUndefined}, {"mat2xdxx", Builtin::kUndefined},
{"m44t3x2f", Builtin::kUndefined}, {"maSS3xVVf", Builtin::kUndefined},
{"RatR22f", Builtin::kUndefined}, {"mF3x9h", Builtin::kUndefined},
{"matx2h", Builtin::kUndefined}, {"VOORRH2h", Builtin::kUndefined},
{"ma3xyf", Builtin::kUndefined}, {"llnarr3773f", Builtin::kUndefined},
{"mat34300", Builtin::kUndefined}, {"a3ooh", Builtin::kUndefined},
{"zz3x3h", Builtin::kUndefined}, {"miitppx1", Builtin::kUndefined},
{"mat3xXXf", Builtin::kUndefined}, {"9II5ann3x4f", Builtin::kUndefined},
{"mataSSrHHYf", Builtin::kUndefined}, {"makkh", Builtin::kUndefined},
{"jatgRx", Builtin::kUndefined}, {"mb3x4", Builtin::kUndefined},
{"mat4xjf", Builtin::kUndefined}, {"at4x2f", Builtin::kUndefined},
{"q4x2f", Builtin::kUndefined}, {"matNN2h", Builtin::kUndefined},
{"at42vv", Builtin::kUndefined}, {"QQt4x2h", Builtin::kUndefined},
{"maffxr", Builtin::kUndefined}, {"mat4xjf", Builtin::kUndefined},
{"mNNw4x38", Builtin::kUndefined}, {"matx3h", Builtin::kUndefined},
{"mrrt4x3h", Builtin::kUndefined}, {"Gat4x3h", Builtin::kUndefined},
{"mat4x4FF", Builtin::kUndefined}, {"at4f", Builtin::kUndefined},
{"marrx4f", Builtin::kUndefined}, {"t4x4h", Builtin::kUndefined},
{"Da4xJJh", Builtin::kUndefined}, {"ma84", Builtin::kUndefined},
{"e2k", Builtin::kUndefined}, {"vecf", Builtin::kUndefined},
{"Jecf", Builtin::kUndefined}, {"ec2h", Builtin::kUndefined},
{"_KKttcH", Builtin::kUndefined}, {"vexxh", Builtin::kUndefined},
{"__qcF", Builtin::kUndefined}, {"vc2qq", Builtin::kUndefined},
{"33e62i", Builtin::kUndefined}, {"6QQott2u", Builtin::kUndefined},
{"v6c2u", Builtin::kUndefined}, {"zzc2O6", Builtin::kUndefined},
{"vyyc3f", Builtin::kUndefined}, {"vcZZ", Builtin::kUndefined},
{"ecWq4f", Builtin::kUndefined}, {"vOO3h", Builtin::kUndefined},
{"oYe3", Builtin::kUndefined}, {"v3", Builtin::kUndefined},
{"Fe3i", Builtin::kUndefined}, {"vwci", Builtin::kUndefined},
{"vefi", Builtin::kUndefined}, {"KKeq3u", Builtin::kUndefined},
{"vFmm3u", Builtin::kUndefined}, {"vecu", Builtin::kUndefined},
{"qc4f", Builtin::kUndefined}, {"vecbb", Builtin::kUndefined},
{"iic4", Builtin::kUndefined}, {"vqOOh", Builtin::kUndefined},
{"vevvTTh", Builtin::kUndefined}, {"veFF4h", Builtin::kUndefined},
{"00PfQ", Builtin::kUndefined}, {"vec4P", Builtin::kUndefined},
{"vec77s", Builtin::kUndefined}, {"vecbbCu", Builtin::kUndefined},
{"vecXXu", Builtin::kUndefined}, {"CCOOec4", Builtin::kUndefined},
};
using BuiltinParseTest = testing::TestWithParam<Case>;
TEST_P(BuiltinParseTest, Parse) {
const char* string = GetParam().string;
Builtin expect = GetParam().value;
EXPECT_EQ(expect, ParseBuiltin(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, BuiltinParseTest, testing::ValuesIn(kInvalidCases));
using BuiltinPrintTest = testing::TestWithParam<Case>;
TEST_P(BuiltinPrintTest, Print) {
Builtin value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, utils::ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinPrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::type

View File

@@ -1,6 +1,6 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate short_name_test.cc
Template file for use with tools/src/cmd/gen to generate builtin_test.cc
To update the generated file, run:
./tools/run gen
@@ -12,9 +12,10 @@ See:
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "short_name") -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/short_name.h"
#include "src/tint/type/builtin.h"
#include <string>

View File

@@ -1,135 +0,0 @@
// 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/type/short_name_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/short_name.h"
#include <string>
#include "gtest/gtest.h"
#include "src/tint/utils/string.h"
namespace tint::type {
namespace {
namespace parse_print_tests {
struct Case {
const char* string;
ShortName value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"mat2x2f", ShortName::kMat2X2F}, {"mat2x2h", ShortName::kMat2X2H},
{"mat2x3f", ShortName::kMat2X3F}, {"mat2x3h", ShortName::kMat2X3H},
{"mat2x4f", ShortName::kMat2X4F}, {"mat2x4h", ShortName::kMat2X4H},
{"mat3x2f", ShortName::kMat3X2F}, {"mat3x2h", ShortName::kMat3X2H},
{"mat3x3f", ShortName::kMat3X3F}, {"mat3x3h", ShortName::kMat3X3H},
{"mat3x4f", ShortName::kMat3X4F}, {"mat3x4h", ShortName::kMat3X4H},
{"mat4x2f", ShortName::kMat4X2F}, {"mat4x2h", ShortName::kMat4X2H},
{"mat4x3f", ShortName::kMat4X3F}, {"mat4x3h", ShortName::kMat4X3H},
{"mat4x4f", ShortName::kMat4X4F}, {"mat4x4h", ShortName::kMat4X4H},
{"vec2f", ShortName::kVec2F}, {"vec2h", ShortName::kVec2H},
{"vec2i", ShortName::kVec2I}, {"vec2u", ShortName::kVec2U},
{"vec3f", ShortName::kVec3F}, {"vec3h", ShortName::kVec3H},
{"vec3i", ShortName::kVec3I}, {"vec3u", ShortName::kVec3U},
{"vec4f", ShortName::kVec4F}, {"vec4h", ShortName::kVec4H},
{"vec4i", ShortName::kVec4I}, {"vec4u", ShortName::kVec4U},
};
static constexpr Case kInvalidCases[] = {
{"at2x2cc", ShortName::kUndefined}, {"l23f", ShortName::kUndefined},
{"matVx2f", ShortName::kUndefined}, {"mat212h", ShortName::kUndefined},
{"mqtJx2h", ShortName::kUndefined}, {"mat2x27ll", ShortName::kUndefined},
{"ppqqt23HH", ShortName::kUndefined}, {"macv", ShortName::kUndefined},
{"bt2xGf", ShortName::kUndefined}, {"mat2iivh", ShortName::kUndefined},
{"8WWt2x3h", ShortName::kUndefined}, {"mxx2x3h", ShortName::kUndefined},
{"mX2x4gg", ShortName::kUndefined}, {"a2xXf", ShortName::kUndefined},
{"mat234f", ShortName::kUndefined}, {"Eat2x4h", ShortName::kUndefined},
{"mPTT2x4h", ShortName::kUndefined}, {"mat2xdxx", ShortName::kUndefined},
{"m44t3x2f", ShortName::kUndefined}, {"maSS3xVVf", ShortName::kUndefined},
{"RatR22f", ShortName::kUndefined}, {"mF3x9h", ShortName::kUndefined},
{"matx2h", ShortName::kUndefined}, {"VOORRH2h", ShortName::kUndefined},
{"ma3xyf", ShortName::kUndefined}, {"llnarr3773f", ShortName::kUndefined},
{"mat34300", ShortName::kUndefined}, {"a3ooh", ShortName::kUndefined},
{"zz3x3h", ShortName::kUndefined}, {"miitppx1", ShortName::kUndefined},
{"mat3xXXf", ShortName::kUndefined}, {"9II5ann3x4f", ShortName::kUndefined},
{"mataSSrHHYf", ShortName::kUndefined}, {"makkh", ShortName::kUndefined},
{"jatgRx", ShortName::kUndefined}, {"mb3x4", ShortName::kUndefined},
{"mat4xjf", ShortName::kUndefined}, {"at4x2f", ShortName::kUndefined},
{"q4x2f", ShortName::kUndefined}, {"matNN2h", ShortName::kUndefined},
{"at42vv", ShortName::kUndefined}, {"QQt4x2h", ShortName::kUndefined},
{"maffxr", ShortName::kUndefined}, {"mat4xjf", ShortName::kUndefined},
{"mNNw4x38", ShortName::kUndefined}, {"matx3h", ShortName::kUndefined},
{"mrrt4x3h", ShortName::kUndefined}, {"Gat4x3h", ShortName::kUndefined},
{"mat4x4FF", ShortName::kUndefined}, {"at4f", ShortName::kUndefined},
{"marrx4f", ShortName::kUndefined}, {"t4x4h", ShortName::kUndefined},
{"Da4xJJh", ShortName::kUndefined}, {"ma84", ShortName::kUndefined},
{"e2k", ShortName::kUndefined}, {"vecf", ShortName::kUndefined},
{"Jecf", ShortName::kUndefined}, {"ec2h", ShortName::kUndefined},
{"_KKttcH", ShortName::kUndefined}, {"vexxh", ShortName::kUndefined},
{"__qcF", ShortName::kUndefined}, {"vc2qq", ShortName::kUndefined},
{"33e62i", ShortName::kUndefined}, {"6QQott2u", ShortName::kUndefined},
{"v6c2u", ShortName::kUndefined}, {"zzc2O6", ShortName::kUndefined},
{"vyyc3f", ShortName::kUndefined}, {"vcZZ", ShortName::kUndefined},
{"ecWq4f", ShortName::kUndefined}, {"vOO3h", ShortName::kUndefined},
{"oYe3", ShortName::kUndefined}, {"v3", ShortName::kUndefined},
{"Fe3i", ShortName::kUndefined}, {"vwci", ShortName::kUndefined},
{"vefi", ShortName::kUndefined}, {"KKeq3u", ShortName::kUndefined},
{"vFmm3u", ShortName::kUndefined}, {"vecu", ShortName::kUndefined},
{"qc4f", ShortName::kUndefined}, {"vecbb", ShortName::kUndefined},
{"iic4", ShortName::kUndefined}, {"vqOOh", ShortName::kUndefined},
{"vevvTTh", ShortName::kUndefined}, {"veFF4h", ShortName::kUndefined},
{"00PfQ", ShortName::kUndefined}, {"vec4P", ShortName::kUndefined},
{"vec77s", ShortName::kUndefined}, {"vecbbCu", ShortName::kUndefined},
{"vecXXu", ShortName::kUndefined}, {"CCOOec4", ShortName::kUndefined},
};
using ShortNameParseTest = testing::TestWithParam<Case>;
TEST_P(ShortNameParseTest, Parse) {
const char* string = GetParam().string;
ShortName expect = GetParam().value;
EXPECT_EQ(expect, ParseShortName(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, ShortNameParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, ShortNameParseTest, testing::ValuesIn(kInvalidCases));
using ShortNamePrintTest = testing::TestWithParam<Case>;
TEST_P(ShortNamePrintTest, Print) {
ShortName value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, utils::ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, ShortNamePrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::type