blob: 13941a63822cc0cd15b92adea5e7aefdf6f3099d [file] [log] [blame] [edit]
// 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