Migrate to functions for delivering test results

This commit is contained in:
JeremyStar™ 2024-03-29 02:53:16 +01:00
parent 51c1259eb3
commit 71d77398c8
2 changed files with 33 additions and 56 deletions

View file

@ -7,12 +7,10 @@ func test_initialization() -> void:
# Check
if !is_framework_loaded():
test_status = 2
test_message = "is_framework_loaded() returned 'false'"
rerror("is_framework_loaded() returned 'false'")
return
test_status = 0
test_message = ""
rok()
# Custom module support
func test_custom_module_support() -> void:
@ -31,29 +29,24 @@ func test_custom_module_support() -> void:
# Check if registered
if callback != "_initialize" and callback != "_pull_config":
test_status = 2
test_message = "Module did not register"
rerror("Module did not register")
return
elif core_test.get_node_or_null("Custom Modules/test_module") == null:
test_status = 2
test_message = "Could not find module node"
rerror("Could not find module node")
return
# Get module
var module_get: CoreBaseModule = core_test.get_custom_module("test_module")
if module_get == null:
test_status = 2
test_message = "Got null from get_custom_module method"
rerror("Got null from get_custom_module method")
return
if module_get != module:
test_status = 2
test_message = "Got invalid node from get_custom_module method"
rerror("Got invalid node from get_custom_module method")
return
# Get string
if module.hello_test() != "Hello Test!":
test_status = 2
test_message = "Module did not return test string"
rerror("Module did not return test string")
return
# Unregister module
@ -62,8 +55,7 @@ func test_custom_module_support() -> void:
# Check if unregistered
if core_test.get_node_or_null("Custom Modules/test_module") == null:
test_status = 0
test_message = "Successfully registered, got, used and unregistered a custom module"
rok("Successfully registered, got, used and unregistered a custom module")
return
func test_reload_config() -> void:
@ -83,18 +75,15 @@ func test_reload_config() -> void:
# Check config
if core_test.config != config:
test_status = 2
test_message = "Got invalid node from config variable"
rerror("Got invalid node from config variable")
return
# Check config in modules
if core_test.logger.config_colored != false or core_test.logger.config_level != CoreTypes.LoggerLevel.NONE or core_test.logui.background.visible != false:
test_status = 2
test_message = "Configuration did not apply all values correctly"
rerror("Configuration did not apply all values correctly")
return
test_status = 0
test_message = ""
rok()
func test_formatted_string() -> void:
# Init CORE
@ -135,5 +124,5 @@ func test_formatted_string() -> void:
var test_formatted: String = "version=" + str(core_test.version_version) + " typerelease=" + str(core_test.version_typerelease) + " semantic=" + str(test_semantic[0]) + "." + str(test_semantic[1]) + "." + str(test_semantic[2]) + " type=" + test_type + " type_technical=" + test_type_technical + " devmode=" + test_devmode + " headless=" + test_headless + " custommodules=" + test_custommodules + " HELLO TEST! #TransRightsAreHumanRights"
# Compare
if await core_test.get_formatted_string(test_raw) != test_formatted: test_status = 2
else: test_status = 0
if await core_test.get_formatted_string(test_raw) != test_formatted: rerror("Test did not return the right value (in '" + test_raw + "', expected '" + test_formatted + "', got '" + await core_test.get_formatted_string(test_raw) + "')")
else: rok()

View file

@ -11,16 +11,14 @@ func test_byte2mib() -> void:
var test_out_flat: float = 49.0
if core_test.misc.byte2mib(test_in, false) != test_out:
test_status = 2
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, false)) + "')"
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, false)) + "')")
return
if core_test.misc.byte2mib(test_in, true) != test_out_flat:
test_status = 2
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, true)) + "')"
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, true)) + "')")
return
test_status = 0
rok()
# mib2byte
func test_mib2byte() -> void:
@ -33,16 +31,14 @@ func test_mib2byte() -> void:
var test_out_flat: float = test_out
if core_test.misc.mib2byte(test_in, false) != test_out:
test_status = 2
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, false)) + "')"
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, false)) + "')")
return
if core_test.misc.mib2byte(test_in, true) != test_out_flat:
test_status = 2
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, true)) + "')"
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, true)) + "')")
return
test_status = 0
rok()
# mib2gib
func test_mib2gib() -> void:
@ -55,16 +51,14 @@ func test_mib2gib() -> void:
var test_out_flat: float = 1.0
if core_test.misc.mib2gib(test_in, false) != test_out:
test_status = 2
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, false)) + "')"
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, false)) + "')")
return
if core_test.misc.mib2gib(test_in, true) != test_out_flat:
test_status = 2
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, true)) + "')"
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, true)) + "')")
return
test_status = 0
rok()
# gib2mib
func test_gib2mib() -> void:
@ -77,16 +71,14 @@ func test_gib2mib() -> void:
var test_out_flat: float = 1500.0
if core_test.misc.gib2mib(test_in, false) != test_out:
test_status = 2
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, false)) + "')"
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, false)) + "')")
return
if core_test.misc.gib2mib(test_in, true) != test_out_flat:
test_status = 2
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, true)) + "')"
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, true)) + "')")
return
test_status = 0
rok()
# format_stringarray
func test_format_stringarray() -> void:
@ -98,11 +90,10 @@ func test_format_stringarray() -> void:
var test_out: String = "StarOpenSource, JeremyStarTM & Contributors"
if core_test.misc.format_stringarray(test_in) != test_out:
test_status = 2
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')"
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')")
return
test_status = 0
rok()
# format_stringarray (chaotic)
func test_format_stringarray_chaotic() -> void:
@ -114,11 +105,10 @@ func test_format_stringarray_chaotic() -> void:
var test_out: String = "aaaaStarOpenSourcebbbb$#!TaaaaJeremyStarTMbbbb :3 aaaaContributorsbbbb"
if core_test.misc.format_stringarray(test_in, "aaaa", "bbbb", "$#!T", " :3 ") != test_out:
test_status = 2
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')"
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')")
return
test_status = 0
rok()
# array_to_stringarray & stringarray_to_array
func test_array_stringarray_conversion() -> void:
@ -130,11 +120,10 @@ func test_array_stringarray_conversion() -> void:
var test_out: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
if core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in)) != test_out:
test_status = 2
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in))) + "')"
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in))) + "')")
return
test_status = 0
rok()
# get_center
func test_get_center() -> void:
@ -147,8 +136,7 @@ func test_get_center() -> void:
var test_out: Vector2 = Vector2(test_in_parent.x/2-test_in_child.x/2, test_in_parent.y/2-test_in_child.y/2)
if core_test.misc.get_center(test_in_parent, test_in_child) != test_out:
test_status = 2
test_message = "Test did not return the right value (in (parent) '" + str(test_in_parent) + "', in (child) '" + str(test_in_child) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.get_center(test_in_parent, test_in_child))) + "')"
rerror("Test did not return the right value (in (parent) '" + str(test_in_parent) + "', in (child) '" + str(test_in_child) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.get_center(test_in_parent, test_in_child))) + "')")
return
test_status = 0
rok()