Files
Grovewright/game/tests/test_launch_options.gd
Steven Wroblewski ab81f66ef0 Stil wählen, merken und fotografieren
F2 wechselt im Spiel den Stil und meldet ihn, --style=NAME wählt ihn
beim Start, und das Spiel merkt sich die Wahl in den Einstellungen.
Das Bildschirmfoto-Werkzeug nimmt Bilder in einem bestimmten Stil und
von der Vitrine auf und zeigt eine zweite Figur mit Namen.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-10-02 12:49:40 +02:00

39 lines
2.1 KiB
GDScript

extends TestCase
func test_without_arguments_the_menu_shows_and_the_default_profile_is_used() -> void:
var options := LaunchOptions.parse(PackedStringArray())
check_eq(options.start, "", "no direct start")
check_eq(options.storage_dir(), "user://", "the user folder itself")
check_eq(options.port, NetLink.DEFAULT_PORT, "the default port")
func test_every_argument_is_read() -> void:
var options := LaunchOptions.parse(PackedStringArray(["--profile=second", "--name=Grace", "--host", "--port=25000"]))
check_eq(options.storage_dir(), "user://profiles/second", "a folder of its own")
check_eq(options.player_name, "Grace", "name")
check_eq(options.start, "host", "opens the world")
check_eq(options.port, 25000, "port")
var joining := LaunchOptions.parse(PackedStringArray(["--join=192.168.1.20:25000"]))
check_eq(joining.start, "join", "joins")
check_eq(joining.address, "192.168.1.20:25000", "address")
check_eq(LaunchOptions.parse(PackedStringArray(["--solo"])).start, "solo", "plays alone")
func test_profile_names_cannot_leave_the_profile_folder() -> void:
check(LaunchOptions.is_valid_profile("Zweiter_2-b"), "letters, digits, - and _")
for name in ["", "../save", "a/b", "a b", "x".repeat(33)]:
check(not LaunchOptions.is_valid_profile(name), "refused: '%s'" % name)
var options := LaunchOptions.parse(PackedStringArray(["--profile=../oops", "--port=70000", "--fly"]))
check_eq(options.storage_dir(), "user://", "a bad profile is ignored")
check_eq(options.port, NetLink.DEFAULT_PORT, "a bad port is ignored")
check_eq(options.ignored, PackedStringArray(["--profile=../oops", "--port=70000", "--fly"]), "everything ignored is listed")
func test_a_style_can_be_chosen() -> void:
check_eq(LaunchOptions.parse(PackedStringArray(["--style=glow"])).style, GlowStyle.KEY, "a known style")
check_eq(LaunchOptions.parse(PackedStringArray()).style, &"", "none without the argument")
var unknown := LaunchOptions.parse(PackedStringArray(["--style=watercolour"]))
check_eq(unknown.style, &"", "an unknown style is not taken")
check_eq(unknown.ignored, PackedStringArray(["--style=watercolour"]), "but listed as ignored")