| // Copyright 2023 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/builtin/diagnostic_rule_test.cc.tmpl |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include <string> |
| |
| #include "gtest/gtest-spi.h" |
| #include "src/tint/builtin/diagnostic_rule.h" |
| #include "src/tint/utils/string.h" |
| |
| namespace tint::builtin { |
| namespace { |
| |
| namespace core_diagnostic_rule_tests { |
| |
| namespace parse_print_tests { |
| |
| struct Case { |
| const char* string; |
| CoreDiagnosticRule value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, Case c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr Case kValidCases[] = { |
| {"derivative_uniformity", CoreDiagnosticRule::kDerivativeUniformity}, |
| }; |
| |
| static constexpr Case kInvalidCases[] = { |
| {"deriative_unccformity", CoreDiagnosticRule::kUndefined}, |
| {"dlivative_3iformiy", CoreDiagnosticRule::kUndefined}, |
| {"derivative_uniforVity", CoreDiagnosticRule::kUndefined}, |
| }; |
| |
| using CoreDiagnosticRuleParseTest = testing::TestWithParam<Case>; |
| |
| TEST_P(CoreDiagnosticRuleParseTest, Parse) { |
| const char* string = GetParam().string; |
| CoreDiagnosticRule expect = GetParam().value; |
| EXPECT_EQ(expect, ParseCoreDiagnosticRule(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCases, CoreDiagnosticRuleParseTest, testing::ValuesIn(kValidCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidCases, |
| CoreDiagnosticRuleParseTest, |
| testing::ValuesIn(kInvalidCases)); |
| |
| using CoreDiagnosticRulePrintTest = testing::TestWithParam<Case>; |
| |
| TEST_P(CoreDiagnosticRulePrintTest, Print) { |
| CoreDiagnosticRule value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, utils::ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCases, CoreDiagnosticRulePrintTest, testing::ValuesIn(kValidCases)); |
| |
| } // namespace parse_print_tests |
| |
| } // namespace core_diagnostic_rule_tests |
| |
| namespace chromium_diagnostic_rule_tests { |
| |
| namespace parse_print_tests { |
| |
| struct Case { |
| const char* string; |
| ChromiumDiagnosticRule value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, Case c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr Case kValidCases[] = { |
| {"unreachable_code", ChromiumDiagnosticRule::kUnreachableCode}, |
| }; |
| |
| static constexpr Case kInvalidCases[] = { |
| {"unreacha1le_code", ChromiumDiagnosticRule::kUndefined}, |
| {"unreachableJcqde", ChromiumDiagnosticRule::kUndefined}, |
| {"unreachable77llode", ChromiumDiagnosticRule::kUndefined}, |
| }; |
| |
| using ChromiumDiagnosticRuleParseTest = testing::TestWithParam<Case>; |
| |
| TEST_P(ChromiumDiagnosticRuleParseTest, Parse) { |
| const char* string = GetParam().string; |
| ChromiumDiagnosticRule expect = GetParam().value; |
| EXPECT_EQ(expect, ParseChromiumDiagnosticRule(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCases, |
| ChromiumDiagnosticRuleParseTest, |
| testing::ValuesIn(kValidCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidCases, |
| ChromiumDiagnosticRuleParseTest, |
| testing::ValuesIn(kInvalidCases)); |
| |
| using ChromiumDiagnosticRulePrintTest = testing::TestWithParam<Case>; |
| |
| TEST_P(ChromiumDiagnosticRulePrintTest, Print) { |
| ChromiumDiagnosticRule value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, utils::ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCases, |
| ChromiumDiagnosticRulePrintTest, |
| testing::ValuesIn(kValidCases)); |
| |
| } // namespace parse_print_tests |
| |
| } // namespace chromium_diagnostic_rule_tests |
| |
| } // namespace |
| } // namespace tint::builtin |