-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from .__init__ import sdl3, TEST_RegisterFunction | ||
|
||
@TEST_RegisterFunction | ||
def TEST_SDL_Init(): | ||
assert sdl3.SDL_Init(0), "SDL_Init failed." | ||
assert sdl3.SDL_GetError() == "".encode(), "SDL_GetError failed." | ||
sdl3.SDL_Quit() | ||
|
||
@TEST_RegisterFunction | ||
def TEST_SDL_CreateWindow(): | ||
assert sdl3.SDL_Init(sdl3.SDL_INIT_VIDEO), "SDL_Init failed." | ||
assert (window := sdl3.SDL_CreateWindow("Test".encode(), 1600, 900, sdl3.SDL_WINDOW_RESIZABLE)), "SDL_CreateWindow failed." | ||
assert sdl3.SDL_GetError() == "".encode(), "SDL_GetError failed." | ||
sdl3.SDL_DestroyWindow(window) | ||
sdl3.SDL_Quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os, sys, atexit | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | ||
|
||
import sdl3 | ||
|
||
functions = [] | ||
|
||
def TEST_RegisterFunction(func): | ||
functions.append(func) | ||
|
||
from tests.TEST_init import * | ||
|
||
@atexit.register | ||
def TEST_RunAllTests(): | ||
if not functions: return | ||
successful, failed = 0, 0 | ||
|
||
for func in functions: | ||
try: | ||
func() | ||
print("\33[32m", f"Test '{func.__name__}' passed.", "\33[0m", sep = "", flush = True) | ||
successful += 1 | ||
|
||
except AssertionError as error: | ||
print("\33[31m", f"Test '{func.__name__}' failed: {error}", "\33[0m", sep = "", flush = True) | ||
failed += 1 | ||
|
||
print("\33[35m", f"{successful} tests passed, {failed} tests failed.", "\33[0m", sep = "", flush = True) | ||
assert not failed, "There are some failed tests." |