Adding log.gd
This commit is contained in:
parent
eb32d6614e
commit
4522259397
547 changed files with 46844 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
# this test suite simulates long running test cases
|
||||
extends GdUnitTestSuite
|
||||
@warning_ignore('unused_parameter')
|
||||
|
||||
var _stack : Array
|
||||
|
||||
func before():
|
||||
# init the stack
|
||||
_stack = []
|
||||
|
||||
func before_test():
|
||||
# clean the stack before every test run
|
||||
_stack.clear()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_multi_yielding_with_fuzzer(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 10):
|
||||
# verify the used stack is cleaned by 'before_test'
|
||||
assert_array(_stack).is_empty()
|
||||
_stack.push_back(1)
|
||||
|
||||
prints("test iteration %d" % fuzzer.iteration_index())
|
||||
prints("4")
|
||||
await get_tree().process_frame
|
||||
prints("3")
|
||||
await get_tree().process_frame
|
||||
prints("2")
|
||||
await get_tree().process_frame
|
||||
prints("1")
|
||||
await get_tree().process_frame
|
||||
prints("Go")
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_multi_yielding_with_fuzzer_fail_after_3_iterations(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 10):
|
||||
prints("test iteration %d" % fuzzer.iteration_index())
|
||||
# should never be greater than 3 because we interuppted after three iterations
|
||||
assert_int(fuzzer.iteration_index()).is_less_equal(3)
|
||||
prints("4")
|
||||
await get_tree().process_frame
|
||||
prints("3")
|
||||
await get_tree().process_frame
|
||||
prints("2")
|
||||
await get_tree().process_frame
|
||||
prints("1")
|
||||
await get_tree().process_frame
|
||||
prints("Go")
|
||||
if fuzzer.iteration_index() >= 3:
|
||||
assert_bool(true).is_false()
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
namespace GdUnit4.Tests.Resources
|
||||
{
|
||||
using static Assertions;
|
||||
|
||||
// will be ignored because of missing `[TestSuite]` anotation
|
||||
public partial class NotATestSuite
|
||||
{
|
||||
[TestCase]
|
||||
public void TestFoo()
|
||||
{
|
||||
AssertBool(true).IsEqual(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout = 1000, do_skip=1==1, skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case2(skip_reason="ignored"):
|
||||
pass
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite ends with success, no failures or errors
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# this test suite ends with error on testcase1 by a timeout
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
# configure test with timeout of 2s
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout=2000):
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
# wait 3s to let the test fail by timeout
|
||||
await await_millis(3000)
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# this test suite fails if (https://github.com/MikeSchulze/gdUnit4/issues/106) not fixed on iterating over testcases
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
add_child(auto_free(Node.new()))
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# this test suite fails on multiple stages and detects orphans
|
||||
extends GdUnitTestSuite
|
||||
|
||||
var _orphans := Array()
|
||||
|
||||
func before():
|
||||
# create a node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
|
||||
func before_test():
|
||||
# create two node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
|
||||
|
||||
# ends with warning and 3 orphan detected
|
||||
func test_case1():
|
||||
# create three node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
|
||||
# ends with error and 4 orphan detected
|
||||
func test_case2():
|
||||
# create four node where never freed (orphan)
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
_orphans.append(Node.new())
|
||||
assert_str("test_case2").override_failure_message("faild on test_case2()").is_empty()
|
||||
|
||||
# we manually freeing the orphans from the simulated testsuite to prevent memory leaks here
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
for orphan in _orphans:
|
||||
orphan.free()
|
||||
_orphans.clear()
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# this test suite fails on multiple stages
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").override_failure_message("failed on after()").is_empty()
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").override_failure_message("failed on before_test()").is_empty()
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").override_failure_message("failed 1 on test_case1()").is_empty()
|
||||
assert_str("test_case1").override_failure_message("failed 2 on test_case1()").is_empty()
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage after()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").override_failure_message("failed on after()").is_empty()
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage after_test()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").override_failure_message("failed on after_test()").is_empty()
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage before()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").override_failure_message("failed on before()").is_empty()
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on stage before_test()
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").override_failure_message("failed on before_test()").is_empty()
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").is_equal("test_case1")
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# this test suite fails on a single test case
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func before():
|
||||
assert_str("suite before").is_equal("suite before")
|
||||
|
||||
func after():
|
||||
assert_str("suite after").is_equal("suite after")
|
||||
|
||||
func before_test():
|
||||
assert_str("test before").is_equal("test before")
|
||||
|
||||
func after_test():
|
||||
assert_str("test after").is_equal("test after")
|
||||
|
||||
func test_case1():
|
||||
assert_str("test_case1").override_failure_message("failed on test_case1()").is_empty()
|
||||
|
||||
func test_case2():
|
||||
assert_str("test_case2").is_equal("test_case2")
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
# this test suite simulates long running test cases
|
||||
extends GdUnitTestSuite
|
||||
@warning_ignore('unused_parameter')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _test_called := 0
|
||||
var _expected_calls :int
|
||||
|
||||
func _init(expected_calls :int):
|
||||
_expected_calls = expected_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
func count_test():
|
||||
_test_called += 1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_execute_3times" : TestCaseStatistics.new(3),
|
||||
"test_execute_5times" : TestCaseStatistics.new(5)
|
||||
}
|
||||
|
||||
var _stack : Array
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
# init the stack
|
||||
_stack = []
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._test_called)\
|
||||
.override_failure_message("Expect test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._test_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
|
||||
|
||||
func before_test():
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
# clean the stack before every test run
|
||||
_stack.clear()
|
||||
|
||||
|
||||
func after_test():
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_execute_3times(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 3):
|
||||
_metrics[__active_test_case].count_test()
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_execute_5times(fuzzer := Fuzzers.rangei(0, 1000), fuzzer_iterations = 5):
|
||||
_metrics[__active_test_case].count_test()
|
||||
pass
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
class_name TestSuiteInvalidParameterizedTests
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func test_no_parameters():
|
||||
assert_that(true).is_equal(true)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_success(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 12],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_failed(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_less_args(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_many_args(a: int, b :int, c :int, d :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_to_less_args_at_index_1(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_invalid_struct(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
["foo"],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_invalid_args(a: int, b :int, expected :int, test_parameters := [
|
||||
[1, 2, 6],
|
||||
[3, "4", 11],
|
||||
[6, 7, 21] ]):
|
||||
pass
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
@warning_ignore('return_value_discarded')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _test_called := 0
|
||||
var _expected_calls :int
|
||||
|
||||
func _init(expected_calls :int):
|
||||
_expected_calls = expected_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
func count_test():
|
||||
_test_called += 1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_parameterized_2times" : TestCaseStatistics.new(2),
|
||||
"test_parameterized_5times" : TestCaseStatistics.new(5)
|
||||
}
|
||||
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._test_called)\
|
||||
.override_failure_message("Expect test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._test_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_calls, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_calls)
|
||||
|
||||
|
||||
func before_test():
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
|
||||
|
||||
func after_test():
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_2times(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true]]):
|
||||
|
||||
_metrics[__active_test_case].count_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_5times(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true],
|
||||
[0, false],
|
||||
[1, true],
|
||||
[1, true]]):
|
||||
|
||||
_metrics[__active_test_case].count_test()
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
@warning_ignore('return_value_discarded')
|
||||
|
||||
|
||||
class TestCaseStatistics:
|
||||
var _testcase_before_called := 0
|
||||
var _testcase_after_called := 0
|
||||
var _expected_testcase_before :int
|
||||
var _expected_testcase_after :int
|
||||
|
||||
func _init(testcase_before_calls := 0, testcase_after_calls := 0):
|
||||
_expected_testcase_before = testcase_before_calls
|
||||
_expected_testcase_after = testcase_after_calls
|
||||
|
||||
func count_test_before_test():
|
||||
_testcase_before_called +=1
|
||||
|
||||
func count_test_after_test():
|
||||
_testcase_after_called +=1
|
||||
|
||||
|
||||
var _metrics = {
|
||||
"test_parameterized_bool_value" : TestCaseStatistics.new(2, 2),
|
||||
"test_parameterized_int_values" : TestCaseStatistics.new(3, 3)
|
||||
}
|
||||
|
||||
var _before_called := 0
|
||||
var _after_called := 0
|
||||
|
||||
|
||||
func before():
|
||||
_before_called += 1
|
||||
|
||||
|
||||
func after():
|
||||
_after_called += 1
|
||||
assert_that(_before_called)\
|
||||
.override_failure_message("Expecting 'before' is called only one times")\
|
||||
.is_equal(1)
|
||||
assert_that(_after_called)\
|
||||
.override_failure_message("Expecting 'after' is called only one times")\
|
||||
.is_equal(1)
|
||||
|
||||
for test_case in _metrics.keys():
|
||||
var statistics := _metrics[test_case] as TestCaseStatistics
|
||||
assert_int(statistics._testcase_before_called)\
|
||||
.override_failure_message("Expect before_test called %s times but is %s for test case %s" % [statistics._expected_testcase_before, statistics._testcase_before_called, test_case])\
|
||||
.is_equal(statistics._expected_testcase_before)
|
||||
assert_int(statistics._testcase_after_called)\
|
||||
.override_failure_message("Expect after_test called %s times but is %s for test case %s" % [statistics._expected_testcase_after, statistics._testcase_after_called, test_case])\
|
||||
.is_equal(statistics._expected_testcase_after)
|
||||
|
||||
|
||||
func before_test():
|
||||
if _metrics.has(__active_test_case):
|
||||
_metrics[__active_test_case].count_test_before_test()
|
||||
|
||||
|
||||
func after_test():
|
||||
if _metrics.has(__active_test_case):
|
||||
_metrics[__active_test_case].count_test_after_test()
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_bool_value(a: int, expected :bool, test_parameters := [
|
||||
[0, false],
|
||||
[1, true]]):
|
||||
|
||||
assert_that(bool(a)).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_int_values(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 12],
|
||||
[6, 7, 8, 21] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_int_values_fail(a: int, b :int, c :int, expected :int, test_parameters := [
|
||||
[1, 2, 3, 6],
|
||||
[3, 4, 5, 11],
|
||||
[6, 7, 8, 22] ]):
|
||||
|
||||
assert_that(a+b+c).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_float_values(a: float, b :float, expected :float, test_parameters := [
|
||||
[2.2, 2.2, 4.4],
|
||||
[2.2, 2.3, 4.5],
|
||||
[3.3, 2.2, 5.5] ]):
|
||||
|
||||
assert_float(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_string_values(a: String, b :String, expected :String, test_parameters := [
|
||||
["2.2", "2.2", "2.22.2"],
|
||||
["foo", "bar", "foobar"],
|
||||
["a", "b", "ab"] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_Vector2_values(a: Vector2, b :Vector2, expected :Vector2, test_parameters := [
|
||||
[Vector2.ONE, Vector2.ONE, Vector2(2, 2)],
|
||||
[Vector2.LEFT, Vector2.RIGHT, Vector2.ZERO],
|
||||
[Vector2.ZERO, Vector2.LEFT, Vector2.LEFT] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_Vector3_values(a: Vector3, b :Vector3, expected :Vector3, test_parameters := [
|
||||
[Vector3.ONE, Vector3.ONE, Vector3(2, 2, 2)],
|
||||
[Vector3.LEFT, Vector3.RIGHT, Vector3.ZERO],
|
||||
[Vector3.ZERO, Vector3.LEFT, Vector3.LEFT] ]):
|
||||
|
||||
assert_that(a+b).is_equal(expected)
|
||||
|
||||
class TestObj extends Resource:
|
||||
var _value :String
|
||||
|
||||
func _init(value :String):
|
||||
_value = value
|
||||
|
||||
func _to_string() -> String:
|
||||
return _value
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_parameterized_obj_values(a: Object, b :Object, expected :String, test_parameters := [
|
||||
[TestObj.new("abc"), TestObj.new("def"), "abcdef"]]):
|
||||
|
||||
assert_that(a.to_string()+b.to_string()).is_equal(expected)
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_dictionary_div_number_types(
|
||||
value : Dictionary,
|
||||
expected : Dictionary,
|
||||
test_parameters : Array = [
|
||||
[{ top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}, { top = 50, bottom = 50, left = 50, right = 50}],
|
||||
[{ top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}, { top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}],
|
||||
[{ top = 50, bottom = 50, left = 50, right = 50}, { top = 50.0, bottom = 50.0, left = 50.0, right = 50.0}],
|
||||
[{ top = 50, bottom = 50, left = 50, right = 50}, { top = 50, bottom = 50, left = 50, right = 50}],
|
||||
]
|
||||
) -> void:
|
||||
assert_that(value).is_equal(expected)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func is_skipped() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func before(do_skip=is_skipped(), skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case1(timeout = 1000, do_skip=1==1, skip_reason="do not run this"):
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore('unused_parameter')
|
||||
func test_case2(skip_reason="ignored"):
|
||||
pass
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
func before():
|
||||
pass
|
||||
|
||||
|
||||
func foo():
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue