1cb93a386Sopenharmony_ci// Copyright (c) 2015-2016 The Khronos Group Inc. 2cb93a386Sopenharmony_ci// 3cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License. 5cb93a386Sopenharmony_ci// You may obtain a copy of the License at 6cb93a386Sopenharmony_ci// 7cb93a386Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8cb93a386Sopenharmony_ci// 9cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and 13cb93a386Sopenharmony_ci// limitations under the License. 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci#include <string> 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ci#include "gmock/gmock.h" 18cb93a386Sopenharmony_ci#include "source/util/string_utils.h" 19cb93a386Sopenharmony_ci#include "test/test_fixture.h" 20cb93a386Sopenharmony_ci#include "test/unit_spirv.h" 21cb93a386Sopenharmony_ci 22cb93a386Sopenharmony_cinamespace spvtools { 23cb93a386Sopenharmony_cinamespace { 24cb93a386Sopenharmony_ci 25cb93a386Sopenharmony_ciusing spvtest::Concatenate; 26cb93a386Sopenharmony_ciusing spvtest::MakeInstruction; 27cb93a386Sopenharmony_ciusing utils::MakeVector; 28cb93a386Sopenharmony_ciusing spvtest::TextToBinaryTest; 29cb93a386Sopenharmony_ciusing testing::Eq; 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ciTEST_F(TextToBinaryTest, Whitespace) { 32cb93a386Sopenharmony_ci std::string input = R"( 33cb93a386Sopenharmony_ci; I'm a proud comment at the beginning of the file 34cb93a386Sopenharmony_ci; I hide: OpCapability Shader 35cb93a386Sopenharmony_ci OpMemoryModel Logical Simple ; comment after instruction 36cb93a386Sopenharmony_ci;;;;;;;; many ;'s 37cb93a386Sopenharmony_ci %glsl450 = OpExtInstImport "GLSL.std.450" 38cb93a386Sopenharmony_ci ; comment indented 39cb93a386Sopenharmony_ci)"; 40cb93a386Sopenharmony_ci 41cb93a386Sopenharmony_ci EXPECT_THAT( 42cb93a386Sopenharmony_ci CompiledInstructions(input), 43cb93a386Sopenharmony_ci Eq(Concatenate({MakeInstruction(SpvOpMemoryModel, 44cb93a386Sopenharmony_ci {uint32_t(SpvAddressingModelLogical), 45cb93a386Sopenharmony_ci uint32_t(SpvMemoryModelSimple)}), 46cb93a386Sopenharmony_ci MakeInstruction(SpvOpExtInstImport, {1}, 47cb93a386Sopenharmony_ci MakeVector("GLSL.std.450"))}))); 48cb93a386Sopenharmony_ci} 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci} // namespace 51cb93a386Sopenharmony_ci} // namespace spvtools 52