blob: 2e2dba47204a9f9dc5ba1b2687c9160eed30f09c [file] [log] [blame] [edit]
// 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_framebuffer_fetch", Extension::kChromiumExperimentalFramebufferFetch},
{"chromium_experimental_pixel_local", Extension::kChromiumExperimentalPixelLocal},
{"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant},
{"chromium_experimental_subgroups", Extension::kChromiumExperimentalSubgroups},
{"chromium_internal_graphite", Extension::kChromiumInternalGraphite},
{"chromium_internal_input_attachments", Extension::kChromiumInternalInputAttachments},
{"chromium_internal_relaxed_uniform_layout", Extension::kChromiumInternalRelaxedUniformLayout},
{"dual_source_blending", Extension::kDualSourceBlending},
{"f16", Extension::kF16},
};
static constexpr Case kInvalidCases[] = {
{"chromium_disableuniformiccy_analysis", Extension::kUndefined},
{"chromil3_disable_unifority_analss", Extension::kUndefined},
{"chromium_disable_Vniformity_analysis", Extension::kUndefined},
{"chromium_experimental_framebuf1er_fetch", Extension::kUndefined},
{"chromium_experiqqntal_framebuffer_fetch", Extension::kUndefined},
{"chromium_experimental_framebuffll77_fetch", Extension::kUndefined},
{"chroqqppum_expermental_pixel_HHocal", Extension::kUndefined},
{"chromium_experimenta_piel_occl", Extension::kUndefined},
{"chromium_exeGimental_pixel_local", Extension::kUndefined},
{"chvomium_experimental_push_constiint", Extension::kUndefined},
{"chromiu8WWexperimental_push_constant", Extension::kUndefined},
{"chromium_experiMental_push_costanxx", Extension::kUndefined},
{"chromiuX_experimentl_sugggroups", Extension::kUndefined},
{"chromiu_exuerimntal_XVbgroups", Extension::kUndefined},
{"chromium_experimen3al_subgroups", Extension::kUndefined},
{"chromium_internal_graphitE", Extension::kUndefined},
{"chromium_nternal_gTTPaphite", Extension::kUndefined},
{"chxxdomium_interal_graphite", Extension::kUndefined},
{"c44romium_internal_input_attachments", Extension::kUndefined},
{"chromium_internal_inputSSaVVtachments", Extension::kUndefined},
{"chrom22Rm_internal_input_atRchments", Extension::kUndefined},
{"chromium_int9rnal_relaxed_Fnifor_layout", Extension::kUndefined},
{"chrmium_internal_relaxed_uniform_layout", Extension::kUndefined},
{"VRhHomium_internal_relaxd_uniform_OOayout", Extension::kUndefined},
{"dual_souyce_bleding", Extension::kUndefined},
{"dualrrllnource_blendiG77", Extension::kUndefined},
{"dual00source_ble4ding", 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