blob: 86a8e40695a97adaba2fc95794ef16eeaac0ef2d [file] [log] [blame]
// 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/address_space_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/address_space.h"
#include <string>
#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;
AddressSpace value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"function", AddressSpace::kFunction}, {"private", AddressSpace::kPrivate},
{"workgroup", AddressSpace::kWorkgroup}, {"uniform", AddressSpace::kUniform},
{"storage", AddressSpace::kStorage}, {"push_constant", AddressSpace::kPushConstant},
};
static constexpr Case kInvalidCases[] = {
{"fccnctin", AddressSpace::kInvalid}, {"ucti3", AddressSpace::kInvalid},
{"functVon", AddressSpace::kInvalid}, {"priv1te", AddressSpace::kInvalid},
{"pqiJate", AddressSpace::kInvalid}, {"privat7ll", AddressSpace::kInvalid},
{"workroppqHH", AddressSpace::kInvalid}, {"workru", AddressSpace::kInvalid},
{"wbkgGoup", AddressSpace::kInvalid}, {"unifiivm", AddressSpace::kInvalid},
{"8WWiform", AddressSpace::kInvalid}, {"uxxform", AddressSpace::kInvalid},
{"sXraggg", AddressSpace::kInvalid}, {"traXe", AddressSpace::kInvalid},
{"stor3ge", AddressSpace::kInvalid}, {"push_constanE", AddressSpace::kInvalid},
{"push_TTPnstant", AddressSpace::kInvalid}, {"puxxdh_constan", AddressSpace::kInvalid},
};
using AddressSpaceParseTest = testing::TestWithParam<Case>;
TEST_P(AddressSpaceParseTest, Parse) {
const char* string = GetParam().string;
AddressSpace expect = GetParam().value;
EXPECT_EQ(expect, ParseAddressSpace(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, AddressSpaceParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, AddressSpaceParseTest, testing::ValuesIn(kInvalidCases));
using AddressSpacePrintTest = testing::TestWithParam<Case>;
TEST_P(AddressSpacePrintTest, Print) {
AddressSpace value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, utils::ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, AddressSpacePrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::ast