forked from CrossGL/crosstl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.py
60 lines (49 loc) · 2.32 KB
/
testing.py
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
import unittest
import crosstl
class TestCodeGeneration(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
def test_cgl_to_glsl_translation(self):
result = crosstl.translate("examples/PerlinNoise.cgl", backend="opengl")
self.assertTrue(result, "GLSL translation failed or returned empty result")
print("################### GLSL ###################")
print(result)
def test_cgl_to_metal_translation(self):
result = crosstl.translate("examples/PerlinNoise.cgl", backend="metal")
self.assertTrue(result, "Metal translation failed or returned empty result")
print("################### Metal ###################")
print(result)
def test_cgl_to_hlsl_translation(self):
result = crosstl.translate("examples/PerlinNoise.cgl", backend="directx")
self.assertTrue(result, "HLSL translation failed or returned empty result")
print("################### HLSL ###################")
print(result)
def test_glsl_to_crossgl_translation(self):
result = crosstl.translate("examples/PerlinNoise.glsl", backend="cgl")
self.assertTrue(
result, "GLSL to CrossGL translation failed or returned empty result"
)
print("################### GLSL TO CrossGL ###################")
print(result)
def test_hlsl_to_crossgl_translation(self):
result = crosstl.translate("examples/PerlinNoise.hlsl", backend="cgl")
self.assertTrue(
result, "HLSL to CrossGL translation failed or returned empty result"
)
print("################### HLSL TO CrossGL ###################")
print(result)
def test_metal_to_crossgl_translation(self):
result = crosstl.translate("examples/PerlinNoise.metal", backend="cgl")
self.assertTrue(
result, "Metal to CrossGL translation failed or returned empty result"
)
print("################### Metal TO CrossGL ###################")
print(result)
def test_translation_errors(self):
with self.assertRaises(Exception):
crosstl.translate("non_existent_file.cgl", backend="opengl")
with self.assertRaises(Exception):
crosstl.translate("examples/PerlinNoise.cgl", backend="invalid_backend")
if __name__ == "__main__":
unittest.main()