| // Copyright 2021 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/extension_test.cc.tmpl |
| // |
| // To regenerate run: './tools/run gen' |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include "src/tint/lang/wgsl/extension.h" |
| |
| #include <gtest/gtest.h> |
| |
| #include <string> |
| |
| #include "src/tint/utils/text/string.h" |
| |
| namespace tint::wgsl { |
| 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[] = { |
| {"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis}, |
| {"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A}, |
| {"chromium_experimental_framebuffer_fetch", Extension::kChromiumExperimentalFramebufferFetch}, |
| {"chromium_experimental_full_ptr_parameters", |
| Extension::kChromiumExperimentalFullPtrParameters}, |
| {"chromium_experimental_pixel_local", Extension::kChromiumExperimentalPixelLocal}, |
| {"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant}, |
| {"chromium_experimental_subgroups", Extension::kChromiumExperimentalSubgroups}, |
| {"chromium_internal_dual_source_blending", Extension::kChromiumInternalDualSourceBlending}, |
| {"chromium_internal_relaxed_uniform_layout", Extension::kChromiumInternalRelaxedUniformLayout}, |
| {"f16", Extension::kF16}, |
| }; |
| |
| static constexpr Case kInvalidCases[] = { |
| {"chromium_disableuniformiccy_analysis", Extension::kUndefined}, |
| {"chromil3_disable_unifority_analss", Extension::kUndefined}, |
| {"chromium_disable_Vniformity_analysis", Extension::kUndefined}, |
| {"chro1ium_experimental_dp4a", Extension::kUndefined}, |
| {"chrJmium_experiqqetal_dp4a", Extension::kUndefined}, |
| {"chromium_experimenll77l_dp4a", Extension::kUndefined}, |
| {"cqqromium_eppperimental_framebuffe_fetcHH", Extension::kUndefined}, |
| {"chrmium_experimvntal_frcmebufer_ftch", Extension::kUndefined}, |
| {"chromium_expebimental_framGbufer_fetch", Extension::kUndefined}, |
| {"chvomium_exiierimental_full_ptr_parameters", Extension::kUndefined}, |
| {"chromium_WWxperimental_full8ptr_parameters", Extension::kUndefined}, |
| {"chromxxum_Mperimental_full_ptr_parameters", Extension::kUndefined}, |
| {"chromum_experimental_pixeX_loggal", Extension::kUndefined}, |
| {"chromium_expVrXmntal_ixel_local", Extension::kUndefined}, |
| {"3hromium_experimental_pixel_local", Extension::kUndefined}, |
| {"chromium_experEmental_push_constant", Extension::kUndefined}, |
| {"chPPomiumexperimental_push_conTTtant", Extension::kUndefined}, |
| {"chromixxm_experimentddl_push_constnt", Extension::kUndefined}, |
| {"chromium_experimental_44ubgroups", Extension::kUndefined}, |
| {"cSSromVVum_experimental_subgroups", Extension::kUndefined}, |
| {"chrmium_e22perimental_suRgrRups", Extension::kUndefined}, |
| {"chroFium_internal_dual_source_bl9ndig", Extension::kUndefined}, |
| {"chrmium_internal_dual_source_blending", Extension::kUndefined}, |
| {"cVromium_interHal_dualOOsouRRce_blening", Extension::kUndefined}, |
| {"chromium_internl_relaxyd_uniform_layout", Extension::kUndefined}, |
| {"chromnnum_internrr77_Gelaxell_uniform_layout", Extension::kUndefined}, |
| {"chromium_intern4l_relaxe00_uniform_layout", Extension::kUndefined}, |
| {"5", Extension::kUndefined}, |
| {"u16", Extension::kUndefined}, |
| {"f", Extension::kUndefined}, |
| }; |
| |
| 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, ToString(value)); |
| } |
| |
| INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionPrintTest, testing::ValuesIn(kValidCases)); |
| |
| } // namespace parse_print_tests |
| |
| } // namespace |
| } // namespace tint::wgsl |