1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // ConstructCompiler_test.cpp
7 // Test the sh::ConstructCompiler interface with different parameters.
8 //
9
10 #include "GLSLANG/ShaderLang.h"
11 #include "angle_gl.h"
12 #include "gtest/gtest.h"
13
14 // Test default parameters.
TEST(ConstructCompilerTest,DefaultParameters)15 TEST(ConstructCompilerTest, DefaultParameters)
16 {
17 ShBuiltInResources resources;
18 sh::InitBuiltInResources(&resources);
19 ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
20 SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
21 ASSERT_NE(nullptr, compiler);
22 sh::Destruct(compiler);
23 }
24
25 // Test invalid MaxDrawBuffers zero.
TEST(ConstructCompilerTest,InvalidMaxDrawBuffers)26 TEST(ConstructCompilerTest, InvalidMaxDrawBuffers)
27 {
28 ShBuiltInResources resources;
29 sh::InitBuiltInResources(&resources);
30 resources.MaxDrawBuffers = 0;
31 ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
32 SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
33 ASSERT_EQ(nullptr, compiler);
34 }
35
36 // Test invalid MaxDualSourceDrawBuffers zero.
TEST(ConstructCompilerTest,InvalidMaxDualSourceDrawBuffers)37 TEST(ConstructCompilerTest, InvalidMaxDualSourceDrawBuffers)
38 {
39 ShBuiltInResources resources;
40 sh::InitBuiltInResources(&resources);
41 resources.EXT_blend_func_extended = 1;
42 resources.MaxDualSourceDrawBuffers = 0;
43 ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
44 SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
45 ASSERT_EQ(nullptr, compiler);
46 }
47