56 lines
2.0 KiB
GDScript3
56 lines
2.0 KiB
GDScript3
|
# GdUnit4 TestSuite
|
||
|
class_name OscSenderTest
|
||
|
extends GdUnitTestSuite
|
||
|
@warning_ignore('unused_parameter')
|
||
|
@warning_ignore('return_value_discarded')
|
||
|
|
||
|
# TestSuite for
|
||
|
const __source = 'res://osc_sender.gd'
|
||
|
|
||
|
|
||
|
func test_create_message_minimal() -> void:
|
||
|
var sender = OSCSender.new()
|
||
|
var result = sender.create_message("/")
|
||
|
assert_bool(result[0] == OK).is_true()
|
||
|
assert_int(result[1].size()).is_equal(8)
|
||
|
assert_str(result[1].get_string_from_ascii()).is_equal("/")
|
||
|
assert_str(result[1].slice(4).get_string_from_ascii()).is_equal(",")
|
||
|
assert_array(Array(result[1])).is_equal([47, 0, 0 , 0, 44, 0, 0, 0])
|
||
|
sender.free()
|
||
|
|
||
|
func test_address_padding0() -> void:
|
||
|
var sender = OSCSender.new()
|
||
|
var result = sender.create_message("/f12")
|
||
|
assert_bool(result[0] == OK).is_true()
|
||
|
assert_int(result[1].size()).is_equal(8)
|
||
|
assert_str(result[1].get_string_from_ascii()).is_equal("/12")
|
||
|
assert_array(Array(result[1])).is_equal([47, 49, 50 , 0, 44, 0, 0, 0])
|
||
|
sender.free()
|
||
|
|
||
|
func test_address_padding1() -> void:
|
||
|
var sender = OSCSender.new()
|
||
|
var result = sender.create_message("/f1")
|
||
|
assert_bool(result[0] == OK).is_true()
|
||
|
assert_int(result[1].size()).is_equal(8)
|
||
|
assert_str(result[1].get_string_from_ascii()).is_equal("/1")
|
||
|
assert_array(Array(result[1])).is_equal([47, 49, 0 , 0, 44, 0, 0, 0])
|
||
|
sender.free()
|
||
|
|
||
|
func test_address_padding2() -> void:
|
||
|
var sender = OSCSender.new()
|
||
|
var result = sender.create_message("/1234")
|
||
|
assert_bool(result[0] == OK).is_true()
|
||
|
assert_int(result[1].size()).is_equal(12)
|
||
|
assert_str(result[1].get_string_from_ascii()).is_equal("/1234")
|
||
|
assert_array(Array(result[1].slice(0, 8))).is_equal([47, 49, 50 , 51, 52, 0, 0, 0])
|
||
|
sender.free()
|
||
|
|
||
|
func test_address_padding3() -> void:
|
||
|
var sender = OSCSender.new()
|
||
|
var result = sender.create_message("/123")
|
||
|
assert_bool(result[0] == OK).is_true()
|
||
|
assert_int(result[1].size()).is_equal(12)
|
||
|
assert_str(result[1].get_string_from_ascii()).is_equal("/123")
|
||
|
assert_array(Array(result[1].slice(0, 8))).is_equal([47, 49, 50 , 51, 0, 0, 0, 0])
|
||
|
sender.free()
|