diff options
| author | historia <[not public]> | 2026-10-06 12:57:23 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-06 12:57:23 -0400 |
| commit | 9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch) | |
| tree | 0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/world/room_test.go | |
| parent | 4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff) | |
| download | thehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz | |
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/world/room_test.go')
| -rw-r--r-- | internal/world/room_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/world/room_test.go b/internal/world/room_test.go index 855eba5..893f858 100644 --- a/internal/world/room_test.go +++ b/internal/world/room_test.go @@ -6,6 +6,8 @@ import ( "testing" "gopkg.in/yaml.v3" + "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/object" ) func writeRoom(t *testing.T, dir string, body string) { @@ -137,3 +139,32 @@ func TestExitDefUnmarshalAlwaysBlocked(t *testing.T) { t.Error("east exit should not have AlwaysBlocked") } } + +func TestRoomObjectMarshalYAMLRoundTripsWander(t *testing.T) { + ro := RoomObject{ + ID: "fence", + WanderRooms: []int{2, 3}, + WanderInterval: 5, + Local: &object.ObjectDef{ + Name: "fence", + Description: behavior.DescList{{Text: "A fence."}}, + }, + } + data, err := yaml.Marshal(ro) + if err != nil { + t.Fatalf("marshal: %v", err) + } + var out RoomObject + if err := yaml.Unmarshal(data, &out); err != nil { + t.Fatalf("unmarshal: %v", err) + } + if len(out.WanderRooms) != 2 || out.WanderRooms[0] != 2 || out.WanderRooms[1] != 3 { + t.Fatalf("wander_rooms round trip = %v, want [2 3]", out.WanderRooms) + } + if out.WanderInterval != 5 { + t.Fatalf("wander_interval round trip = %v, want 5", out.WanderInterval) + } + if out.Local == nil || out.Local.Name != "fence" { + t.Fatalf("local object lost: %+v", out.Local) + } +} |
