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 }
23
24 // Test invalid MaxDrawBuffers zero.
TEST(ConstructCompilerTest,InvalidMaxDrawBuffers)25 TEST(ConstructCompilerTest, InvalidMaxDrawBuffers)
26 {
27 ShBuiltInResources resources;
28 sh::InitBuiltInResources(&resources);
29 resources.MaxDrawBuffers = 0;
30 ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
31 SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
32 ASSERT_EQ(nullptr, compiler);
33 }
34
35 // Test invalid MaxDualSourceDrawBuffers zero.
TEST(ConstructCompilerTest,InvalidMaxDualSourceDrawBuffers)36 TEST(ConstructCompilerTest, InvalidMaxDualSourceDrawBuffers)
37 {
38 ShBuiltInResources resources;
39 sh::InitBuiltInResources(&resources);
40 resources.EXT_blend_func_extended = 1;
41 resources.MaxDualSourceDrawBuffers = 0;
42 ShHandle compiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_WEBGL_SPEC,
43 SH_GLSL_COMPATIBILITY_OUTPUT, &resources);
44 ASSERT_EQ(nullptr, compiler);
45 }
46