forked from woofmeow/straywild
Add(test): chat validation
This commit is contained in:
parent
b1061f0165
commit
c20bb35929
3 changed files with 23 additions and 0 deletions
21
tests/chat_validation.gd
Normal file
21
tests/chat_validation.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extends SceneTree
|
||||
|
||||
const MainScene: PackedScene = preload("res://main/main.tscn")
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
func _run() -> void:
|
||||
## Regular whitespace should be stripped
|
||||
assert(NetworkChatProtocol.sanitize_body(" a") == "a", "Leading space not trimmed")
|
||||
assert(NetworkChatProtocol.sanitize_body("b ") == "b", "Trailing space not trimmed")
|
||||
assert(NetworkChatProtocol.sanitize_body("a b") == "a b", "Innocent whitespace culled")
|
||||
|
||||
## Some examples of Unicode whitespace that should be stripped
|
||||
const em_space := " " # U+2003 EM SPACE
|
||||
assert(NetworkChatProtocol.sanitize_body(em_space + "a") == "a")
|
||||
const braille_space := "⠀" # U+2800 BRAILLE PATTERN BLANK
|
||||
assert(NetworkChatProtocol.sanitize_body(braille_space + "a") == "a")
|
||||
|
||||
print("Chat validation: PASS")
|
||||
quit(0)
|
||||
1
tests/chat_validation.gd.uid
Normal file
1
tests/chat_validation.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ohemhv2sf5g4
|
||||
Loading…
Add table
Add a link
Reference in a new issue