1 // Copyright (c) 2015-2016 The Khronos Group Inc.
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/test_fixture.h"
19 #include "test/unit_spirv.h"
20
21 namespace spvtools {
22 namespace {
23
24 using spvtest::Concatenate;
25 using spvtest::MakeInstruction;
26 using spvtest::MakeVector;
27 using spvtest::TextToBinaryTest;
28 using testing::Eq;
29
TEST_F(TextToBinaryTest,Whitespace)30 TEST_F(TextToBinaryTest, Whitespace) {
31 std::string input = R"(
32 ; I'm a proud comment at the beginning of the file
33 ; I hide: OpCapability Shader
34 OpMemoryModel Logical Simple ; comment after instruction
35 ;;;;;;;; many ;'s
36 %glsl450 = OpExtInstImport "GLSL.std.450"
37 ; comment indented
38 )";
39
40 EXPECT_THAT(
41 CompiledInstructions(input),
42 Eq(Concatenate({MakeInstruction(SpvOpMemoryModel,
43 {uint32_t(SpvAddressingModelLogical),
44 uint32_t(SpvMemoryModelSimple)}),
45 MakeInstruction(SpvOpExtInstImport, {1},
46 MakeVector("GLSL.std.450"))})));
47 }
48
49 } // namespace
50 } // namespace spvtools
51