Path: blob/main_old/src/tests/compiler_tests/PruneEmptyDeclarations_test.cpp
1693 views
//1// Copyright 2016 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// PruneEmptyDeclarations_test.cpp:6// Tests for pruning empty declarations.7//89#include "GLSLANG/ShaderLang.h"10#include "angle_gl.h"11#include "gtest/gtest.h"12#include "tests/test_utils/compiler_test.h"1314using namespace sh;1516namespace17{1819class PruneEmptyDeclarationsTest : public MatchOutputCodeTest20{21public:22PruneEmptyDeclarationsTest()23: MatchOutputCodeTest(GL_VERTEX_SHADER, 0, SH_GLSL_COMPATIBILITY_OUTPUT)24{}25};2627TEST_F(PruneEmptyDeclarationsTest, EmptyDeclarationStartsDeclaratorList)28{29const std::string shaderString =30"precision mediump float;\n"31"uniform float u;\n"32"void main()\n"33"{\n"34" float, f;\n"35" gl_Position = vec4(u * f);\n"36"}\n";37compile(shaderString);38ASSERT_TRUE(foundInCode("float _uf"));39ASSERT_TRUE(notFoundInCode("float, _uf"));40ASSERT_TRUE(notFoundInCode("float, f"));41ASSERT_TRUE(notFoundInCode("float _u, _uf"));42}4344TEST_F(PruneEmptyDeclarationsTest, EmptyStructDeclarationWithQualifiers)45{46const std::string shaderString =47"precision mediump float;\n"48"const struct S { float f; };\n"49"uniform S s;"50"void main()\n"51"{\n"52" gl_Position = vec4(s.f);\n"53"}\n";54compile(shaderString);55ASSERT_TRUE(foundInCode("struct _uS"));56ASSERT_TRUE(foundInCode("uniform _uS"));57ASSERT_TRUE(notFoundInCode("const struct _uS"));58}5960} // namespace616263