| // 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_barycentric_coord", Extension::kChromiumExperimentalBarycentricCoord}, |
| {"chromium_experimental_dynamic_binding", Extension::kChromiumExperimentalDynamicBinding}, |
| {"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}, |
| {"primitive_index", Extension::kPrimitiveIndex}, |
| {"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_barcentric_coord", Extension::kUndefined}, |
| {"chromium_experimentl_barycentzzc_coord", Extension::kUndefined}, |
| {"chromium_expperimental1barycentric_coori", Extension::kUndefined}, |
| {"chromium_experimental_dyXXamic_binding", Extension::kUndefined}, |
| {"chromi55m_eIIperimental_dynnami99_binding", Extension::kUndefined}, |
| {"chroSSium_experiaaYntal_dynamic_binrrHHng", Extension::kUndefined}, |
| {"chromum_xperimentalframebuffHrkkfetch", Extension::kUndefined}, |
| {"chrojium_xRReimental_frgmebuffer_fetch", Extension::kUndefined}, |
| {"hromium_experimental_ramebbffer_fetch", Extension::kUndefined}, |
| {"chromium_experimental_ijmediate", Extension::kUndefined}, |
| {"chromium_experimental_imediate", Extension::kUndefined}, |
| {"cromum_experimentalqimmediate", Extension::kUndefined}, |
| {"chromium_experimNNntal_pixel_loca", Extension::kUndefined}, |
| {"chromium_expermentalpivvel_local", Extension::kUndefined}, |
| {"chromium_experiQQental_pixl_local", Extension::kUndefined}, |
| {"hromium_exprimertal_subgroup_ffatrix", Extension::kUndefined}, |
| {"chromium_ejperimental_subgroup_matrix", Extension::kUndefined}, |
| {"chromium_expewim8n2al_subgroupNNmatrix", Extension::kUndefined}, |
| {"chromium_internl_graphite", Extension::kUndefined}, |
| {"chromium_irrternal_graphite", Extension::kUndefined}, |
| {"cGromium_internal_graphite", Extension::kUndefined}, |
| {"chromium_internal_input_attFFchments", Extension::kUndefined}, |
| {"chromium_iEteral_input_attahment", Extension::kUndefined}, |
| {"chrmium_internal_inprrt_attachments", Extension::kUndefined}, |
| {"lip_distanes", Extension::kUndefined}, |
| {"DXp_diJJtances", Extension::kUndefined}, |
| {"cl8pdistane", Extension::kUndefined}, |
| {"dul_okrc_blen11ing", Extension::kUndefined}, |
| {"dua_source_blending", Extension::kUndefined}, |
| {"duJl_source_blendig", Extension::kUndefined}, |
| {"c16", Extension::kUndefined}, |
| {"fO6", Extension::kUndefined}, |
| {"_KKttvv", Extension::kUndefined}, |
| {"pr8mitive_nxxex", Extension::kUndefined}, |
| {"primitveFqqd__x", Extension::kUndefined}, |
| {"priitive_indeqq", Extension::kUndefined}, |
| {"subgr6u33O", Extension::kUndefined}, |
| {"s96grQttupoo", Extension::kUndefined}, |
| {"sugro66ps", 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_print", LanguageFeature::kChromiumPrint}, |
| {"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[] = { |
| {"66roOium_przznt", LanguageFeature::kUndefined}, |
| {"chromium_pryynt", LanguageFeature::kUndefined}, |
| {"chroHHiuZpriZ", LanguageFeature::kUndefined}, |
| {"chromium_qeWWting_exper44metal", LanguageFeature::kUndefined}, |
| {"chromium_teting_eOOperimental", LanguageFeature::kUndefined}, |
| {"oohhoYum_testing_experimenal", LanguageFeature::kUndefined}, |
| {"chomium_testin_shippe", LanguageFeature::kUndefined}, |
| {"chomium_testing_shiFped", LanguageFeature::kUndefined}, |
| {"chromium_testinwshipped", LanguageFeature::kUndefined}, |
| {"chromiumtesting_shippff_with_kiGKswitch", LanguageFeature::kUndefined}, |
| {"chromium_testing_shippeq_with_killsKKitch", LanguageFeature::kUndefined}, |
| {"cFromium_testing_shipped_wimmh_killswi3ch", LanguageFeature::kUndefined}, |
| {"chromium_testing_uimplemented", LanguageFeature::kUndefined}, |
| {"chromium_teqtin_unimplemented", LanguageFeature::kUndefined}, |
| {"chrobibm_testing_unimplemented", LanguageFeature::kUndefined}, |
| {"chromium_tesiing_unsafe_experimentl", LanguageFeature::kUndefined}, |
| {"chromium_testing_unafe_exOOerimentaq", LanguageFeature::kUndefined}, |
| {"chromium_testing_unsafTTvvexperimental", LanguageFeature::kUndefined}, |
| {"packed_4x8_integer_dotFFproduct", LanguageFeature::kUndefined}, |
| {"packfd_4x8_ineQerP00ot_product", LanguageFeature::kUndefined}, |
| {"packed_4x8_intPger_dot_product", LanguageFeature::kUndefined}, |
| {"pointer_compossste_accs77", LanguageFeature::kUndefined}, |
| {"Cointer_compobbite_acceRRs", LanguageFeature::kUndefined}, |
| {"pointer_composite_accesXX", LanguageFeature::kUndefined}, |
| {"qOCCadoly_and_OOeadwrite_storage_textures", LanguageFeature::kUndefined}, |
| {"rsadonly_and_reawrite_storageutextLres", LanguageFeature::kUndefined}, |
| {"readonly_and_readwrite_storage_tXxtures", LanguageFeature::kUndefined}, |
| {"sized_binding_arra", LanguageFeature::kUndefined}, |
| {"izeqq_bidOng_arra", LanguageFeature::kUndefined}, |
| {"sized_bind22ng_array", LanguageFeature::kUndefined}, |
| {"tezyel_bXXffer", LanguageFeature::kUndefined}, |
| {"exelPbufVVers", LanguageFeature::kUndefined}, |
| {"texel_Cufernn", LanguageFeature::kUndefined}, |
| {"nrestrqqcHHed_oinAAer_parameters", LanguageFeature::kUndefined}, |
| {"unrestricted_pointer_parametrs", LanguageFeature::kUndefined}, |
| {"unfestricKKed_pointer_parameer", 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 |