Home | History | Annotate | Download | only in link
      1 // Copyright (c) 2017 Pierre Moreau
      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 #include <string>
     16 
     17 #include "gmock/gmock.h"
     18 #include "test/link/linker_fixture.h"
     19 
     20 namespace spvtools {
     21 namespace {
     22 
     23 using BinaryVersion = spvtest::LinkerTest;
     24 
     25 TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) {
     26   // clang-format off
     27   spvtest::Binaries binaries = {
     28       {
     29           SpvMagicNumber,
     30           0x00000300u,
     31           SPV_GENERATOR_CODEPLAY,
     32           1u,  // NOTE: Bound
     33           0u   // NOTE: Schema; reserved
     34       },
     35       {
     36           SpvMagicNumber,
     37           0x00000600u,
     38           SPV_GENERATOR_CODEPLAY,
     39           1u,  // NOTE: Bound
     40           0u   // NOTE: Schema; reserved
     41       },
     42       {
     43           SpvMagicNumber,
     44           0x00000100u,
     45           SPV_GENERATOR_CODEPLAY,
     46           1u,  // NOTE: Bound
     47           0u   // NOTE: Schema; reserved
     48       }
     49   };
     50   // clang-format on
     51   spvtest::Binary linked_binary;
     52 
     53   ASSERT_EQ(SPV_SUCCESS, Link(binaries, &linked_binary));
     54   EXPECT_THAT(GetErrorMessage(), std::string());
     55 
     56   EXPECT_EQ(0x00000600u, linked_binary[1]);
     57 }
     58 
     59 }  // namespace
     60 }  // namespace spvtools
     61