text_to_binary.composite_test.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2018 Google LLC
  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. // Assembler tests for instructions in the "Group Instrucions" section of the
  15. // SPIR-V spec.
  16. #include <string>
  17. #include <vector>
  18. #include "gmock/gmock.h"
  19. #include "test/test_fixture.h"
  20. #include "test/unit_spirv.h"
  21. using ::testing::Eq;
  22. using ::testing::HasSubstr;
  23. namespace spvtools {
  24. namespace {
  25. using spvtest::Concatenate;
  26. using CompositeRoundTripTest = RoundTripTest;
  27. TEST_F(CompositeRoundTripTest, Good) {
  28. std::string spirv = "%2 = OpCopyLogical %1 %3\n";
  29. std::string disassembly = EncodeAndDecodeSuccessfully(
  30. spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4);
  31. EXPECT_THAT(disassembly, Eq(spirv));
  32. }
  33. TEST_F(CompositeRoundTripTest, V13Bad) {
  34. std::string spirv = "%2 = OpCopyLogical %1 %3\n";
  35. std::string err = CompileFailure(spirv, SPV_ENV_UNIVERSAL_1_3);
  36. EXPECT_THAT(err, HasSubstr("Invalid Opcode name 'OpCopyLogical'"));
  37. }
  38. } // namespace
  39. } // namespace spvtools