blob: 283088db46662eb718ef755d57e50c1514ed3861 [file] [log] [blame]
// Copyright 2021 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/extension_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/extension.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;
Extension value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"f16", Extension::kF16},
{"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A},
{"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis},
{"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant},
};
static constexpr Case kInvalidCases[] = {
{"cc6", Extension::kInvalid},
{"s", Extension::kInvalid},
{"HH6", Extension::kInvalid},
{"chro1ium_experimental_dp4a", Extension::kInvalid},
{"chrJmium_experiqqetal_dp4a", Extension::kInvalid},
{"chromium_experimenll77l_dp4a", Extension::kInvalid},
{"chromiumppdisableqquniformity_aalysHHs", Extension::kInvalid},
{"chromiu_disable_unifovmitc_analyi", Extension::kInvalid},
{"chromium_diable_uGbformity_analysis", Extension::kInvalid},
{"chvomium_experimental_push_constiint", Extension::kInvalid},
{"chromiu8WWexperimental_push_constant", Extension::kInvalid},
{"chromium_experiMental_push_costanxx", Extension::kInvalid},
};
using ExtensionParseTest = testing::TestWithParam<Case>;
TEST_P(ExtensionParseTest, Parse) {
const char* string = GetParam().string;
Extension expect = GetParam().value;
EXPECT_EQ(expect, ParseExtension(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, ExtensionParseTest, testing::ValuesIn(kInvalidCases));
using ExtensionPrintTest = testing::TestWithParam<Case>;
TEST_P(ExtensionPrintTest, Print) {
Extension value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, utils::ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionPrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::ast