1fd4e5da5Sopenharmony_ci// Copyright (c) 2015-2016 The Khronos Group Inc.
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_ci#include <limits>
16fd4e5da5Sopenharmony_ci#include <string>
17fd4e5da5Sopenharmony_ci#include <utility>
18fd4e5da5Sopenharmony_ci#include <vector>
19fd4e5da5Sopenharmony_ci
20fd4e5da5Sopenharmony_ci#include "gmock/gmock.h"
21fd4e5da5Sopenharmony_ci#include "source/opcode.h"
22fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h"
23fd4e5da5Sopenharmony_ci
24fd4e5da5Sopenharmony_cinamespace spvtools {
25fd4e5da5Sopenharmony_cinamespace {
26fd4e5da5Sopenharmony_ci
27fd4e5da5Sopenharmony_ciusing ::spvtest::EnumCase;
28fd4e5da5Sopenharmony_ciusing ::testing::Eq;
29fd4e5da5Sopenharmony_ciusing GeneratorMagicNumberTest =
30fd4e5da5Sopenharmony_ci    ::testing::TestWithParam<EnumCase<spv_generator_t>>;
31fd4e5da5Sopenharmony_ci
32fd4e5da5Sopenharmony_ciTEST_P(GeneratorMagicNumberTest, Single) {
33fd4e5da5Sopenharmony_ci  EXPECT_THAT(std::string(spvGeneratorStr(GetParam().value())),
34fd4e5da5Sopenharmony_ci              GetParam().name());
35fd4e5da5Sopenharmony_ci}
36fd4e5da5Sopenharmony_ci
37fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(
38fd4e5da5Sopenharmony_ci    Registered, GeneratorMagicNumberTest,
39fd4e5da5Sopenharmony_ci    ::testing::ValuesIn(std::vector<EnumCase<spv_generator_t>>{
40fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_KHRONOS, "Khronos"},
41fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_LUNARG, "LunarG"},
42fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_VALVE, "Valve"},
43fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_CODEPLAY, "Codeplay"},
44fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_NVIDIA, "NVIDIA"},
45fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_ARM, "ARM"},
46fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_KHRONOS_LLVM_TRANSLATOR,
47fd4e5da5Sopenharmony_ci         "Khronos LLVM/SPIR-V Translator"},
48fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_KHRONOS_ASSEMBLER, "Khronos SPIR-V Tools Assembler"},
49fd4e5da5Sopenharmony_ci        {SPV_GENERATOR_KHRONOS_GLSLANG, "Khronos Glslang Reference Front End"},
50fd4e5da5Sopenharmony_ci    }));
51fd4e5da5Sopenharmony_ci
52fd4e5da5Sopenharmony_ciINSTANTIATE_TEST_SUITE_P(
53fd4e5da5Sopenharmony_ci    Unregistered, GeneratorMagicNumberTest,
54fd4e5da5Sopenharmony_ci    ::testing::ValuesIn(std::vector<EnumCase<spv_generator_t>>{
55fd4e5da5Sopenharmony_ci        // We read registered entries from the SPIR-V XML Registry file
56fd4e5da5Sopenharmony_ci        // which can change over time.
57fd4e5da5Sopenharmony_ci        {spv_generator_t(1000), "Unknown"},
58fd4e5da5Sopenharmony_ci        {spv_generator_t(9999), "Unknown"},
59fd4e5da5Sopenharmony_ci    }));
60fd4e5da5Sopenharmony_ci
61fd4e5da5Sopenharmony_ci}  // namespace
62fd4e5da5Sopenharmony_ci}  // namespace spvtools
63