blob: 184d68acbf94d6c6e1575a1ce03cea4634a8bfba [file] [log] [blame]
// Copyright 2022 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/core/builtin_value_test.cc.tmpl
//
// To regenerate run: './tools/run gen'
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/lang/core/builtin_value.h"
#include <gtest/gtest.h>
#include <string>
#include "src/tint/utils/text/string.h"
namespace tint::core {
namespace {
namespace parse_print_tests {
struct Case {
const char* string;
BuiltinValue value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"__point_size", BuiltinValue::kPointSize},
{"clip_distances", BuiltinValue::kClipDistances},
{"frag_depth", BuiltinValue::kFragDepth},
{"front_facing", BuiltinValue::kFrontFacing},
{"global_invocation_id", BuiltinValue::kGlobalInvocationId},
{"instance_index", BuiltinValue::kInstanceIndex},
{"local_invocation_id", BuiltinValue::kLocalInvocationId},
{"local_invocation_index", BuiltinValue::kLocalInvocationIndex},
{"num_workgroups", BuiltinValue::kNumWorkgroups},
{"position", BuiltinValue::kPosition},
{"sample_index", BuiltinValue::kSampleIndex},
{"sample_mask", BuiltinValue::kSampleMask},
{"subgroup_invocation_id", BuiltinValue::kSubgroupInvocationId},
{"subgroup_size", BuiltinValue::kSubgroupSize},
{"vertex_index", BuiltinValue::kVertexIndex},
{"workgroup_id", BuiltinValue::kWorkgroupId},
};
static constexpr Case kInvalidCases[] = {
{"_ccpoint_siz", BuiltinValue::kUndefined},
{"_3poi_ile", BuiltinValue::kUndefined},
{"__poiVt_size", BuiltinValue::kUndefined},
{"clip1distances", BuiltinValue::kUndefined},
{"cqqiJ_distanes", BuiltinValue::kUndefined},
{"clip_dllstance77", BuiltinValue::kUndefined},
{"frqqgppepHHh", BuiltinValue::kUndefined},
{"fv_dcpt", BuiltinValue::kUndefined},
{"frabGdeth", BuiltinValue::kUndefined},
{"front_facvnii", BuiltinValue::kUndefined},
{"frWWnt_faci8g", BuiltinValue::kUndefined},
{"fxxonM_facig", BuiltinValue::kUndefined},
{"gXobalgginvocationid", BuiltinValue::kUndefined},
{"goVal_uvocatioX_id", BuiltinValue::kUndefined},
{"global_in3ocation_id", BuiltinValue::kUndefined},
{"instancE_index", BuiltinValue::kUndefined},
{"nsTTance_PPndex", BuiltinValue::kUndefined},
{"nstancxx_indddx", BuiltinValue::kUndefined},
{"local_invocation_i44", BuiltinValue::kUndefined},
{"local_invoVVatSSon_id", BuiltinValue::kUndefined},
{"local_inRoctionR2id", BuiltinValue::kUndefined},
{"local_in9oation_iFdex", BuiltinValue::kUndefined},
{"local_invocation_inde", BuiltinValue::kUndefined},
{"local_OOnvoVtiRRn_index", BuiltinValue::kUndefined},
{"num_workgyups", BuiltinValue::kUndefined},
{"num_Glr77rnngroups", BuiltinValue::kUndefined},
{"num_wo04kgroups", BuiltinValue::kUndefined},
{"osooon", BuiltinValue::kUndefined},
{"posizzn", BuiltinValue::kUndefined},
{"poiippt1o", BuiltinValue::kUndefined},
{"sample_iXXdex", BuiltinValue::kUndefined},
{"5nnample_99IIdex", BuiltinValue::kUndefined},
{"samYlaaHHrrndeSS", BuiltinValue::kUndefined},
{"aHkk_mask", BuiltinValue::kUndefined},
{"jRRmpl_gsk", BuiltinValue::kUndefined},
{"smple_mbk", BuiltinValue::kUndefined},
{"subgroupjinvocation_id", BuiltinValue::kUndefined},
{"subgroup_invocaion_id", BuiltinValue::kUndefined},
{"subroup_inqocatin_id", BuiltinValue::kUndefined},
{"subNNoup_size", BuiltinValue::kUndefined},
{"subgrupsizvv", BuiltinValue::kUndefined},
{"sugroup_sizQQ", BuiltinValue::kUndefined},
{"vrtexinderf", BuiltinValue::kUndefined},
{"vertex_indjx", BuiltinValue::kUndefined},
{"v82wNNex_idex", BuiltinValue::kUndefined},
{"wrkgroup_id", BuiltinValue::kUndefined},
{"workgrrrup_id", BuiltinValue::kUndefined},
{"wGrkgroup_id", BuiltinValue::kUndefined},
};
using BuiltinValueParseTest = testing::TestWithParam<Case>;
TEST_P(BuiltinValueParseTest, Parse) {
const char* string = GetParam().string;
BuiltinValue expect = GetParam().value;
EXPECT_EQ(expect, ParseBuiltinValue(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinValueParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, BuiltinValueParseTest, testing::ValuesIn(kInvalidCases));
using BuiltinValuePrintTest = testing::TestWithParam<Case>;
TEST_P(BuiltinValuePrintTest, Print) {
BuiltinValue value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinValuePrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::core