// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //////////////////////////////////////////////////////////////////////////////// // File generated by tools/src/cmd/gen // using the template: // src/tint/ast/builtin_value_test.cc.tmpl // // Do not modify this file directly //////////////////////////////////////////////////////////////////////////////// #include "src/tint/ast/builtin_value.h" #include #include "src/tint/ast/test_helper.h" #include "src/tint/utils/string.h" namespace tint::ast { 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[] = { {"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}, {"vertex_index", BuiltinValue::kVertexIndex}, {"workgroup_id", BuiltinValue::kWorkgroupId}, }; static constexpr Case kInvalidCases[] = { {"fragdeccth", BuiltinValue::kUndefined}, {"flaget3", BuiltinValue::kUndefined}, {"fVag_depth", BuiltinValue::kUndefined}, {"1ront_facing", BuiltinValue::kUndefined}, {"front_fJcqng", BuiltinValue::kUndefined}, {"frllnt_facin77", BuiltinValue::kUndefined}, {"global_invoqqtionppHid", BuiltinValue::kUndefined}, {"clvbal_inocaionid", BuiltinValue::kUndefined}, {"global_Gvocation_id", BuiltinValue::kUndefined}, {"invtance_iniiex", BuiltinValue::kUndefined}, {"8nstanceWWindex", BuiltinValue::kUndefined}, {"insxxanceindex", BuiltinValue::kUndefined}, {"lXcal_invoation_igg", BuiltinValue::kUndefined}, {"Xocal_nvocatin_Vd", BuiltinValue::kUndefined}, {"local_invoca3ion_id", BuiltinValue::kUndefined}, {"local_invocation_indeE", BuiltinValue::kUndefined}, {"loTTal_invPPcatin_index", BuiltinValue::kUndefined}, {"loal_invocadxxion_index", BuiltinValue::kUndefined}, {"num_work44roups", BuiltinValue::kUndefined}, {"num_wVVrkgSSoups", BuiltinValue::kUndefined}, {"Rum_wokgrou2Rs", BuiltinValue::kUndefined}, {"oFi9ion", BuiltinValue::kUndefined}, {"postion", BuiltinValue::kUndefined}, {"ROOoHiiVn", BuiltinValue::kUndefined}, {"samply_inde", BuiltinValue::kUndefined}, {"snrrmpl77l_indGx", BuiltinValue::kUndefined}, {"00ample4index", BuiltinValue::kUndefined}, {"smoo_mask", BuiltinValue::kUndefined}, {"sampzemask", BuiltinValue::kUndefined}, {"ppaplii1_mas", BuiltinValue::kUndefined}, {"vertex_iXXdex", BuiltinValue::kUndefined}, {"5nnertex_99IIdex", BuiltinValue::kUndefined}, {"verYeaaHHrrndeSS", BuiltinValue::kUndefined}, {"workkgHo_i", BuiltinValue::kUndefined}, {"worRgoupjid", BuiltinValue::kUndefined}, {"wrkgrupbid", BuiltinValue::kUndefined}, }; using BuiltinValueParseTest = testing::TestWithParam; 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; TEST_P(BuiltinValuePrintTest, Print) { BuiltinValue value = GetParam().value; const char* expect = GetParam().string; EXPECT_EQ(expect, utils::ToString(value)); } INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinValuePrintTest, testing::ValuesIn(kValidCases)); } // namespace parse_print_tests } // namespace } // namespace tint::ast