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