From ced1b85c619a65a9de210acb2d3d150616b88457 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 14 May 2026 15:05:07 +0200 Subject: [PATCH] test(B.5): exercise i32 sign-correctness for BuildPickUp.placement The original test only used placement=0, which encodes identically under WriteInt32 and WriteUInt32. Add a -1 case so a future regression to the unsigned writer would actually fail the test. Flagged by Task 1 code review. --- .../Messages/InteractRequestsTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/AcDream.Core.Net.Tests/Messages/InteractRequestsTests.cs b/tests/AcDream.Core.Net.Tests/Messages/InteractRequestsTests.cs index f251cf4..c36e54f 100644 --- a/tests/AcDream.Core.Net.Tests/Messages/InteractRequestsTests.cs +++ b/tests/AcDream.Core.Net.Tests/Messages/InteractRequestsTests.cs @@ -66,4 +66,22 @@ public sealed class InteractRequestsTests Assert.Equal(0, BinaryPrimitives.ReadInt32LittleEndian(body.AsSpan(20))); } + + [Fact] + public void BuildPickUp_NegativePlacement_WritesSignedLittleEndian() + { + // Sign-correctness guard: placement is i32 on the wire (ACE + // GameActionPutItemInContainer.Handle reads ReadInt32). A + // placement=0 test would pass even if the builder used + // WriteUInt32, so we also exercise a negative value where the + // unsigned/signed encodings would diverge. + byte[] body = InteractRequests.BuildPickUp( + gameActionSequence: 1, + itemGuid: 0x1u, + containerGuid: 0x2u, + placement: -1); + + Assert.Equal(-1, + BinaryPrimitives.ReadInt32LittleEndian(body.AsSpan(20))); + } }