| // Copyright 2025 The Dawn & Tint Authors |
| // |
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are met: |
| // |
| // 1. Redistributions of source code must retain the above copyright notice, this |
| // list of conditions and the following disclaimer. |
| // |
| // 2. Redistributions in binary form must reproduce the above copyright notice, |
| // this list of conditions and the following disclaimer in the documentation |
| // and/or other materials provided with the distribution. |
| // |
| // 3. Neither the name of the copyright holder nor the names of its |
| // contributors may be used to endorse or promote products derived from |
| // this software without specific prior written permission. |
| // |
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| //////////////////////////////////////////////////////////////////////////////// |
| // File generated by 'tools/src/cmd/gen' using the template: |
| // src/tint/lang/wgsl/enums_test.cc.tmpl |
| // |
| // To regenerate run: './tools/run gen' |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include <string> |
| |
| #include "gtest/gtest.h" |
| |
| #include "src/tint/lang/wgsl/enums.h" |
| #include "src/tint/utils/text/string.h" |
| |
| namespace tint::wgsl { |
| namespace { |
| |
| namespace core_diagnostic_rule_tests { |
| namespace parse_print_tests { |
| |
| struct CoreDiagnosticRuleCase { |
| const char* string; |
| CoreDiagnosticRule value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, CoreDiagnosticRuleCase c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr CoreDiagnosticRuleCase kValidCoreDiagnosticRuleCases[] = { |
| {"derivative_uniformity", CoreDiagnosticRule::kDerivativeUniformity}, |
| {"subgroup_uniformity", CoreDiagnosticRule::kSubgroupUniformity}, |
| }; |
| |
| static constexpr CoreDiagnosticRuleCase kInvalidCoreDiagnosticRuleCases[] = { |
| {"deriative_unccformity", CoreDiagnosticRule::kUndefined}, |
| {"dlivative_3iformiy", CoreDiagnosticRule::kUndefined}, |
| {"derivative_uniforVity", CoreDiagnosticRule::kUndefined}, |
| {"s1bgroup_uniformity", CoreDiagnosticRule::kUndefined}, |
| {"subgrouqq_unifJrmty", CoreDiagnosticRule::kUndefined}, |
| {"sub77roup_ulliformity", CoreDiagnosticRule::kUndefined}, |
| }; |
| |
| using CoreDiagnosticRuleParseTest = testing::TestWithParam<CoreDiagnosticRuleCase>; |
| |
| TEST_P(CoreDiagnosticRuleParseTest, Parse) { |
| const char* string = GetParam().string; |
| CoreDiagnosticRule expect = GetParam().value; |
| EXPECT_EQ(expect, ParseCoreDiagnosticRule(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCoreDiagnosticRuleCases, |
| CoreDiagnosticRuleParseTest, |
| testing::ValuesIn(kValidCoreDiagnosticRuleCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidCoreDiagnosticRuleCases, |
| CoreDiagnosticRuleParseTest, |
| testing::ValuesIn(kInvalidCoreDiagnosticRuleCases)); |
| |
| using CoreDiagnosticRulePrintTest = testing::TestWithParam<CoreDiagnosticRuleCase>; |
| |
| TEST_P(CoreDiagnosticRulePrintTest, Print) { |
| CoreDiagnosticRule value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCoreDiagnosticRuleCases, |
| CoreDiagnosticRulePrintTest, |
| testing::ValuesIn(kValidCoreDiagnosticRuleCases)); |
| |
| } // namespace parse_print_tests |
| } // namespace core_diagnostic_rule_tests |
| |
| namespace chromium_diagnostic_rule_tests { |
| namespace parse_print_tests { |
| |
| struct ChromiumDiagnosticRuleCase { |
| const char* string; |
| ChromiumDiagnosticRule value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, ChromiumDiagnosticRuleCase c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr ChromiumDiagnosticRuleCase kValidChromiumDiagnosticRuleCases[] = { |
| {"subgroup_matrix_uniformity", ChromiumDiagnosticRule::kSubgroupMatrixUniformity}, |
| {"unreachable_code", ChromiumDiagnosticRule::kUnreachableCode}, |
| }; |
| |
| static constexpr ChromiumDiagnosticRuleCase kInvalidChromiumDiagnosticRuleCases[] = { |
| {"subgroppHp_matriqq_uiformity", ChromiumDiagnosticRule::kUndefined}, |
| {"subroup_matrcx_niformit", ChromiumDiagnosticRule::kUndefined}, |
| {"subroupGmatrbx_uniformity", ChromiumDiagnosticRule::kUndefined}, |
| {"vnriiachable_code", ChromiumDiagnosticRule::kUndefined}, |
| {"unreac8ablWW_code", ChromiumDiagnosticRule::kUndefined}, |
| {"unreMchablxxcode", ChromiumDiagnosticRule::kUndefined}, |
| }; |
| |
| using ChromiumDiagnosticRuleParseTest = testing::TestWithParam<ChromiumDiagnosticRuleCase>; |
| |
| TEST_P(ChromiumDiagnosticRuleParseTest, Parse) { |
| const char* string = GetParam().string; |
| ChromiumDiagnosticRule expect = GetParam().value; |
| EXPECT_EQ(expect, ParseChromiumDiagnosticRule(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidChromiumDiagnosticRuleCases, |
| ChromiumDiagnosticRuleParseTest, |
| testing::ValuesIn(kValidChromiumDiagnosticRuleCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidChromiumDiagnosticRuleCases, |
| ChromiumDiagnosticRuleParseTest, |
| testing::ValuesIn(kInvalidChromiumDiagnosticRuleCases)); |
| |
| using ChromiumDiagnosticRulePrintTest = testing::TestWithParam<ChromiumDiagnosticRuleCase>; |
| |
| TEST_P(ChromiumDiagnosticRulePrintTest, Print) { |
| ChromiumDiagnosticRule value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidChromiumDiagnosticRuleCases, |
| ChromiumDiagnosticRulePrintTest, |
| testing::ValuesIn(kValidChromiumDiagnosticRuleCases)); |
| |
| } // namespace parse_print_tests |
| } // namespace chromium_diagnostic_rule_tests |
| |
| namespace diagnostic_severity_tests { |
| namespace parse_print_tests { |
| |
| struct DiagnosticSeverityCase { |
| const char* string; |
| DiagnosticSeverity value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, DiagnosticSeverityCase c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr DiagnosticSeverityCase kValidDiagnosticSeverityCases[] = { |
| {"error", DiagnosticSeverity::kError}, |
| {"info", DiagnosticSeverity::kInfo}, |
| {"off", DiagnosticSeverity::kOff}, |
| {"warning", DiagnosticSeverity::kWarning}, |
| }; |
| |
| static constexpr DiagnosticSeverityCase kInvalidDiagnosticSeverityCases[] = { |
| {"eggor", DiagnosticSeverity::kUndefined}, {"VoX", DiagnosticSeverity::kUndefined}, |
| {"erro3", DiagnosticSeverity::kUndefined}, {"infE", DiagnosticSeverity::kUndefined}, |
| {"TTPfo", DiagnosticSeverity::kUndefined}, {"xxnfo", DiagnosticSeverity::kUndefined}, |
| {"44ff", DiagnosticSeverity::kUndefined}, {"oSVVf", DiagnosticSeverity::kUndefined}, |
| {"RR2", DiagnosticSeverity::kUndefined}, {"wFni9g", DiagnosticSeverity::kUndefined}, |
| {"waring", DiagnosticSeverity::kUndefined}, {"VOORRHng", DiagnosticSeverity::kUndefined}, |
| }; |
| |
| using DiagnosticSeverityParseTest = testing::TestWithParam<DiagnosticSeverityCase>; |
| |
| TEST_P(DiagnosticSeverityParseTest, Parse) { |
| const char* string = GetParam().string; |
| DiagnosticSeverity expect = GetParam().value; |
| EXPECT_EQ(expect, ParseDiagnosticSeverity(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidDiagnosticSeverityCases, |
| DiagnosticSeverityParseTest, |
| testing::ValuesIn(kValidDiagnosticSeverityCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidDiagnosticSeverityCases, |
| DiagnosticSeverityParseTest, |
| testing::ValuesIn(kInvalidDiagnosticSeverityCases)); |
| |
| using DiagnosticSeverityPrintTest = testing::TestWithParam<DiagnosticSeverityCase>; |
| |
| TEST_P(DiagnosticSeverityPrintTest, Print) { |
| DiagnosticSeverity value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidDiagnosticSeverityCases, |
| DiagnosticSeverityPrintTest, |
| testing::ValuesIn(kValidDiagnosticSeverityCases)); |
| |
| } // namespace parse_print_tests |
| } // namespace diagnostic_severity_tests |
| |
| namespace parse_print_tests { |
| |
| struct ExtensionCase { |
| const char* string; |
| Extension value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, ExtensionCase c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr ExtensionCase kValidExtensionCases[] = { |
| {"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis}, |
| {"chromium_experimental_framebuffer_fetch", Extension::kChromiumExperimentalFramebufferFetch}, |
| {"chromium_experimental_immediate", Extension::kChromiumExperimentalImmediate}, |
| {"chromium_experimental_pixel_local", Extension::kChromiumExperimentalPixelLocal}, |
| {"chromium_experimental_subgroup_matrix", Extension::kChromiumExperimentalSubgroupMatrix}, |
| {"chromium_internal_graphite", Extension::kChromiumInternalGraphite}, |
| {"chromium_internal_input_attachments", Extension::kChromiumInternalInputAttachments}, |
| {"clip_distances", Extension::kClipDistances}, |
| {"dual_source_blending", Extension::kDualSourceBlending}, |
| {"f16", Extension::kF16}, |
| {"subgroups", Extension::kSubgroups}, |
| }; |
| |
| static constexpr ExtensionCase kInvalidExtensionCases[] = { |
| {"chromium_disable_ynifority_analysis", Extension::kUndefined}, |
| {"c77nromium_disable_rrniformity_analysGll", Extension::kUndefined}, |
| {"chromium_disable_uniform00ty_4nalysis", Extension::kUndefined}, |
| {"chomium_experiooetal_fraebuffer_fetch", Extension::kUndefined}, |
| {"chromium_experimentl_framebufzzr_fetch", Extension::kUndefined}, |
| {"chromium_expperimental1framebuffer_fetci", Extension::kUndefined}, |
| {"chromium_experimental_immediXXte", Extension::kUndefined}, |
| {"chromium55eIIperimental_immenni99te", Extension::kUndefined}, |
| {"chraamiuSS_experimentaHHr_immediaYe", Extension::kUndefined}, |
| {"homHumkkeperimental_pixel_local", Extension::kUndefined}, |
| {"chromim_egperimental_pRRjel_loal", Extension::kUndefined}, |
| {"cromiumbexperimental_pixellocal", Extension::kUndefined}, |
| {"chrjmium_experimental_subgroup_matrix", Extension::kUndefined}, |
| {"chromium_experimental_subgrop_matrix", Extension::kUndefined}, |
| {"chromqumexpermental_subgroup_matrix", Extension::kUndefined}, |
| {"chromium_intenalNNgraphite", Extension::kUndefined}, |
| {"chromiuminternal_gvaphite", Extension::kUndefined}, |
| {"chromium_internal_grphitQQ", Extension::kUndefined}, |
| {"chromirm_ffnternalinpt_attachments", Extension::kUndefined}, |
| {"chromium_internal_input_attachmenjs", Extension::kUndefined}, |
| {"chwwomiu2_interNNal_inpu_att8chments", Extension::kUndefined}, |
| {"cli_distances", Extension::kUndefined}, |
| {"clip_disrrances", Extension::kUndefined}, |
| {"clip_diGtances", Extension::kUndefined}, |
| {"dual_source_blendFFng", Extension::kUndefined}, |
| {"dEl_surce_bending", Extension::kUndefined}, |
| {"drra_source_blending", Extension::kUndefined}, |
| {"1", Extension::kUndefined}, |
| {"DJ1", Extension::kUndefined}, |
| {"", Extension::kUndefined}, |
| {"ubgrk1p", Extension::kUndefined}, |
| {"subroups", Extension::kUndefined}, |
| {"Jubgrups", Extension::kUndefined}, |
| }; |
| |
| using ExtensionParseTest = testing::TestWithParam<ExtensionCase>; |
| |
| TEST_P(ExtensionParseTest, Parse) { |
| const char* string = GetParam().string; |
| Extension expect = GetParam().value; |
| EXPECT_EQ(expect, ParseExtension(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidExtensionCases, |
| ExtensionParseTest, |
| testing::ValuesIn(kValidExtensionCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidExtensionCases, |
| ExtensionParseTest, |
| testing::ValuesIn(kInvalidExtensionCases)); |
| |
| using ExtensionPrintTest = testing::TestWithParam<ExtensionCase>; |
| |
| TEST_P(ExtensionPrintTest, Print) { |
| Extension value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidExtensionCases, |
| ExtensionPrintTest, |
| testing::ValuesIn(kValidExtensionCases)); |
| |
| } // namespace parse_print_tests |
| |
| namespace parse_print_tests { |
| |
| struct LanguageFeatureCase { |
| const char* string; |
| LanguageFeature value; |
| }; |
| |
| inline std::ostream& operator<<(std::ostream& out, LanguageFeatureCase c) { |
| return out << "'" << std::string(c.string) << "'"; |
| } |
| |
| static constexpr LanguageFeatureCase kValidLanguageFeatureCases[] = { |
| {"chromium_testing_experimental", LanguageFeature::kChromiumTestingExperimental}, |
| {"chromium_testing_shipped", LanguageFeature::kChromiumTestingShipped}, |
| {"chromium_testing_shipped_with_killswitch", |
| LanguageFeature::kChromiumTestingShippedWithKillswitch}, |
| {"chromium_testing_unimplemented", LanguageFeature::kChromiumTestingUnimplemented}, |
| {"chromium_testing_unsafe_experimental", LanguageFeature::kChromiumTestingUnsafeExperimental}, |
| {"packed_4x8_integer_dot_product", LanguageFeature::kPacked4X8IntegerDotProduct}, |
| {"pointer_composite_access", LanguageFeature::kPointerCompositeAccess}, |
| {"readonly_and_readwrite_storage_textures", |
| LanguageFeature::kReadonlyAndReadwriteStorageTextures}, |
| {"sized_binding_array", LanguageFeature::kSizedBindingArray}, |
| {"texel_buffers", LanguageFeature::kTexelBuffers}, |
| {"unrestricted_pointer_parameters", LanguageFeature::kUnrestrictedPointerParameters}, |
| }; |
| |
| static constexpr LanguageFeatureCase kInvalidLanguageFeatureCases[] = { |
| {"chcomium_testing_experimental", LanguageFeature::kUndefined}, |
| {"chromium_testing_experimentaO", LanguageFeature::kUndefined}, |
| {"chrovvium_testing_ettperi__entaKK", LanguageFeature::kUndefined}, |
| {"chromi5m_xxestig_shippe8", LanguageFeature::kUndefined}, |
| {"qqhromuF___estin_shipped", LanguageFeature::kUndefined}, |
| {"chromium_tetiqqg_shipped", LanguageFeature::kUndefined}, |
| {"ch33omiu66_testing_shipped_with_iOlswitch", LanguageFeature::kUndefined}, |
| {"chromium_testing_ship9ed_ttooth_kQQl6switch", LanguageFeature::kUndefined}, |
| {"chromium_te66ing_shipped_with_killswitch", LanguageFeature::kUndefined}, |
| {"chromium_txstinOz_66nimlemented", LanguageFeature::kUndefined}, |
| {"cyyromium_testing_unimplemented", LanguageFeature::kUndefined}, |
| {"chromiHHm_ZestZng_uimlemented", LanguageFeature::kUndefined}, |
| {"cWWomium_44qsting_unsafe_experimental", LanguageFeature::kUndefined}, |
| {"chromium_tOOstng_unsafe_experimental", LanguageFeature::kUndefined}, |
| {"cromioomtesting_unsafe_hxpYrimental", LanguageFeature::kUndefined}, |
| {"paked_48_integer_dot_roduct", LanguageFeature::kUndefined}, |
| {"paked_4x8_integer_dFt_product", LanguageFeature::kUndefined}, |
| {"paced_4x8_integer_dot_prodwct", LanguageFeature::kUndefined}, |
| {"pointer_omposiGKaccesff", LanguageFeature::kUndefined}, |
| {"poiqKter_composite_access", LanguageFeature::kUndefined}, |
| {"pFinter_compo3ite_ammcess", LanguageFeature::kUndefined}, |
| {"readonly_nd_readwrite_storage_textures", LanguageFeature::kUndefined}, |
| {"readonly_nd_readwrite_storage_textureq", LanguageFeature::kUndefined}, |
| {"readonby_and_readwritebbstorae_textures", LanguageFeature::kUndefined}, |
| {"sizd_binding_array", LanguageFeature::kUndefined}, |
| {"siqd_biOOding_array", LanguageFeature::kUndefined}, |
| {"siTTed_binding_avvray", LanguageFeature::kUndefined}, |
| {"texel_bufFFers", LanguageFeature::kUndefined}, |
| {"exel_PffQ0ers", LanguageFeature::kUndefined}, |
| {"texel_buffPrs", LanguageFeature::kUndefined}, |
| {"unrestricted_77sointer_parameter", LanguageFeature::kUndefined}, |
| {"unrbbstricted_pointCr_paramRRters", LanguageFeature::kUndefined}, |
| {"unrestrictXXd_pointer_parameters", LanguageFeature::kUndefined}, |
| }; |
| |
| using LanguageFeatureParseTest = testing::TestWithParam<LanguageFeatureCase>; |
| |
| TEST_P(LanguageFeatureParseTest, Parse) { |
| const char* string = GetParam().string; |
| LanguageFeature expect = GetParam().value; |
| EXPECT_EQ(expect, ParseLanguageFeature(string)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidLanguageFeatureCases, |
| LanguageFeatureParseTest, |
| testing::ValuesIn(kValidLanguageFeatureCases)); |
| INSTANTIATE_TEST_SUITE_P(InvalidLanguageFeatureCases, |
| LanguageFeatureParseTest, |
| testing::ValuesIn(kInvalidLanguageFeatureCases)); |
| |
| using LanguageFeaturePrintTest = testing::TestWithParam<LanguageFeatureCase>; |
| |
| TEST_P(LanguageFeaturePrintTest, Print) { |
| LanguageFeature value = GetParam().value; |
| const char* expect = GetParam().string; |
| EXPECT_EQ(expect, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidLanguageFeatureCases, |
| LanguageFeaturePrintTest, |
| testing::ValuesIn(kValidLanguageFeatureCases)); |
| |
| } // namespace parse_print_tests |
| |
| } // namespace |
| } // namespace tint::wgsl |