// 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
