Add(test): chat validation

This commit is contained in:
Toes | Robin Ury 2026-08-21 07:19:34 -04:00
parent b1061f0165
commit c20bb35929
No known key found for this signature in database
GPG key ID: A5DAA8C945CA3941
3 changed files with 23 additions and 0 deletions

21
tests/chat_validation.gd Normal file
View 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)

View file

@ -0,0 +1 @@
uid://ohemhv2sf5g4