text_to_binary.composite_test.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_TEXT_TO_BINARY_OPTION_NONE,
  31. SPV_ENV_UNIVERSAL_1_4);
  32. EXPECT_THAT(disassembly, Eq(spirv));
  33. }
  34. TEST_F(CompositeRoundTripTest, V13Bad) {
  35. std::string spirv = "%2 = OpCopyLogical %1 %3\n";
  36. std::string err = CompileFailure(spirv, SPV_ENV_UNIVERSAL_1_3);
  37. EXPECT_THAT(err, HasSubstr("Invalid Opcode name 'OpCopyLogical'"));
  38. }
  39. } // namespace
  40. } // namespace spvtools