1fd4e5da5Sopenharmony_ci// Copyright (c) 2018 Google LLC
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_ci// Assembler tests for instructions in the "Group Instrucions" section of the
16fd4e5da5Sopenharmony_ci// SPIR-V spec.
17fd4e5da5Sopenharmony_ci
18fd4e5da5Sopenharmony_ci#include <string>
19fd4e5da5Sopenharmony_ci#include <vector>
20fd4e5da5Sopenharmony_ci
21fd4e5da5Sopenharmony_ci#include "gmock/gmock.h"
22fd4e5da5Sopenharmony_ci#include "test/test_fixture.h"
23fd4e5da5Sopenharmony_ci#include "test/unit_spirv.h"
24fd4e5da5Sopenharmony_ci
25fd4e5da5Sopenharmony_ciusing ::testing::Eq;
26fd4e5da5Sopenharmony_ciusing ::testing::HasSubstr;
27fd4e5da5Sopenharmony_ci
28fd4e5da5Sopenharmony_cinamespace spvtools {
29fd4e5da5Sopenharmony_cinamespace {
30fd4e5da5Sopenharmony_ci
31fd4e5da5Sopenharmony_ciusing spvtest::Concatenate;
32fd4e5da5Sopenharmony_ci
33fd4e5da5Sopenharmony_ciusing CompositeRoundTripTest = RoundTripTest;
34fd4e5da5Sopenharmony_ci
35fd4e5da5Sopenharmony_ciTEST_F(CompositeRoundTripTest, Good) {
36fd4e5da5Sopenharmony_ci  std::string spirv = "%2 = OpCopyLogical %1 %3\n";
37fd4e5da5Sopenharmony_ci  std::string disassembly = EncodeAndDecodeSuccessfully(
38fd4e5da5Sopenharmony_ci      spirv, SPV_BINARY_TO_TEXT_OPTION_NONE, SPV_ENV_UNIVERSAL_1_4);
39fd4e5da5Sopenharmony_ci  EXPECT_THAT(disassembly, Eq(spirv));
40fd4e5da5Sopenharmony_ci}
41fd4e5da5Sopenharmony_ci
42fd4e5da5Sopenharmony_ciTEST_F(CompositeRoundTripTest, V13Bad) {
43fd4e5da5Sopenharmony_ci  std::string spirv = "%2 = OpCopyLogical %1 %3\n";
44fd4e5da5Sopenharmony_ci  std::string err = CompileFailure(spirv, SPV_ENV_UNIVERSAL_1_3);
45fd4e5da5Sopenharmony_ci  EXPECT_THAT(err, HasSubstr("Invalid Opcode name 'OpCopyLogical'"));
46fd4e5da5Sopenharmony_ci}
47fd4e5da5Sopenharmony_ci
48fd4e5da5Sopenharmony_ci}  // namespace
49fd4e5da5Sopenharmony_ci}  // namespace spvtools
50