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