generator_magic_number_test.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include <limits>
  15. #include <string>
  16. #include <utility>
  17. #include <vector>
  18. #include "gmock/gmock.h"
  19. #include "source/opcode.h"
  20. #include "test/unit_spirv.h"
  21. namespace spvtools {
  22. namespace {
  23. using ::spvtest::EnumCase;
  24. using ::testing::Eq;
  25. using GeneratorMagicNumberTest =
  26. ::testing::TestWithParam<EnumCase<spv_generator_t>>;
  27. TEST_P(GeneratorMagicNumberTest, Single) {
  28. EXPECT_THAT(std::string(spvGeneratorStr(GetParam().value())),
  29. GetParam().name());
  30. }
  31. INSTANTIATE_TEST_SUITE_P(
  32. Registered, GeneratorMagicNumberTest,
  33. ::testing::ValuesIn(std::vector<EnumCase<spv_generator_t>>{
  34. {SPV_GENERATOR_KHRONOS, "Khronos"},
  35. {SPV_GENERATOR_LUNARG, "LunarG"},
  36. {SPV_GENERATOR_VALVE, "Valve"},
  37. {SPV_GENERATOR_CODEPLAY, "Codeplay"},
  38. {SPV_GENERATOR_NVIDIA, "NVIDIA"},
  39. {SPV_GENERATOR_ARM, "ARM"},
  40. {SPV_GENERATOR_KHRONOS_LLVM_TRANSLATOR,
  41. "Khronos LLVM/SPIR-V Translator"},
  42. {SPV_GENERATOR_KHRONOS_ASSEMBLER, "Khronos SPIR-V Tools Assembler"},
  43. {SPV_GENERATOR_KHRONOS_GLSLANG, "Khronos Glslang Reference Front End"},
  44. }));
  45. INSTANTIATE_TEST_SUITE_P(
  46. Unregistered, GeneratorMagicNumberTest,
  47. ::testing::ValuesIn(std::vector<EnumCase<spv_generator_t>>{
  48. // We read registered entries from the SPIR-V XML Registry file
  49. // which can change over time.
  50. {spv_generator_t(1000), "Unknown"},
  51. {spv_generator_t(9999), "Unknown"},
  52. }));
  53. } // namespace
  54. } // namespace spvtools