MCPcopy Index your code
hub / github.com/EngoEngine/engo / TestShaderCompilation

Function TestShaderCompilation

common/render_shaders_test.go:38–59  ·  view source on GitHub ↗

TestShaderCompilation tests whether the `LoadShader` method will indeed report errors iff (one of) the GLSL-shaders is incorrect.

(t *testing.T)

Source from the content-addressed store, hash-verified

36// TestShaderCompilation tests whether the `LoadShader` method will indeed report errors iff
37// (one of) the GLSL-shaders is incorrect.
38func TestShaderCompilation(t *testing.T) {
39 engo.Run(engo.RunOptions{
40 NoRun: true,
41 HeadlessMode: true,
42 }, &testScene{})
43 engo.CreateWindow("", 100, 100, false, 1)
44 defer engo.DestroyWindow()
45
46 var err error
47
48 _, err = LoadShader(correctVertShader, correctFragShader)
49 assert.NoError(t, err)
50
51 _, err = LoadShader(correctVertShader, incorrectFragShader)
52 assert.IsType(t, FragmentShaderCompilationError{}, err)
53
54 _, err = LoadShader(incorrectVertShader, correctFragShader)
55 assert.IsType(t, VertexShaderCompilationError{}, err)
56
57 _, err = LoadShader(incorrectVertShader, incorrectFragShader)
58 assert.Error(t, err) // don't really care which one it is
59}
60
61var correctVertShader = `
62attribute vec2 in_Position;

Callers

nothing calls this directly

Calls 5

RunFunction · 0.92
CreateWindowFunction · 0.92
DestroyWindowFunction · 0.92
LoadShaderFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected