-
Notifications
You must be signed in to change notification settings - Fork 260
/
Test_ShaderPreprocessor.cpp
68 lines (58 loc) · 2.39 KB
/
Test_ShaderPreprocessor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "Test.h"
#include <string>
#include "ShaderMgr.h"
#include "ShaderPreprocessor.h"
using namespace pymol;
#define TEST_SETUP \
PyMOLInstance pymol; \
auto G = pymol.G(); \
[[maybe_unused]] bool quiet = true; \
ShaderPreprocessor shaderPreprocessor(G, CShaderMgr::GetRawShaderCache());
/**
* C++ 23's std::string_view::contains
* @param str The string to search
* @param query The string to search for
* @return true if the string contains the query
*/
static constexpr bool contains(std::string_view str, std::string_view query)
{
return str.find(query) != std::string_view::npos;
}
// TEST_CASE("Shader Precessor Default", "[ShaderPreprocessor]")
// {
// TEST_SETUP
// REQUIRE(contains(shaderPreprocessor.getSource("line.vs"), "void main()"));
// }
// TEST_CASE("Shader Precessor IfDef", "[ShaderPreprocessor]")
// {
// TEST_SETUP
// REQUIRE(!contains(shaderPreprocessor.getSource("line.vs"), "gl_PointSize"));
// shaderPreprocessor.setVar("PYMOL_WEBGL_IOS", true);
// shaderPreprocessor.invalidate("line.vs");
// REQUIRE(contains(shaderPreprocessor.getSource("line.vs"), "gl_PointSize"));
// }
// TEST_CASE("Shader Precessor Ifndef", "[ShaderPreprocessor]")
// {
// TEST_SETUP
// REQUIRE(contains(
// shaderPreprocessor.getSource("line.vs"), "attribute float a_line_position;"));
// shaderPreprocessor.setVar("gl_VertexID_enabled", true);
// shaderPreprocessor.invalidate("line.vs");
// REQUIRE(!contains(
// shaderPreprocessor.getSource("line.vs"), "attribute float a_line_position;"));
// }
// TEST_CASE("Shader Precessor Else", "[ShaderPreprocessor]")
// {
// TEST_SETUP
// REQUIRE(contains(
// shaderPreprocessor.getSource("line.vs"), "a_LINE_POSITION = a_line_position;"));
// shaderPreprocessor.setVar("gl_VertexID_enabled", true);
// shaderPreprocessor.invalidate("line.vs");
// REQUIRE(contains(shaderPreprocessor.getSource("line.vs"), "a_LINE_POSITION = mod"));
// }
// TEST_CASE("Shader Precessor Include", "[ShaderPreprocessor]")
// {
// TEST_SETUP
// REQUIRE(contains(
// shaderPreprocessor.getSource("line.vs"), "uniform mat3 g_NormalMatrix;"));
// }