Skip to content

Comments

Fix Windows test failures due to ArrayPool buffer sizing#1000

Merged
adamhathcock merged 2 commits intoadam/async-rar-aifrom
copilot/sub-pr-996
Oct 29, 2025
Merged

Fix Windows test failures due to ArrayPool buffer sizing#1000
adamhathcock merged 2 commits intoadam/async-rar-aifrom
copilot/sub-pr-996

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Windows tests failed because ArrayPool<byte>.Shared.Rent() returns buffers larger than requested on Windows but not on Linux. Tests used test.Length (actual rented size) instead of the requested size for reads and comparisons.

Changes

  • SharpCompressStreamTest.cs: Changed Read() calls to use explicit size 0x1000 instead of test.Length
  • Array comparisons: Use .Take(0x1000) to compare only the requested portion of rented buffers
// Before (fails on Windows when ArrayPool returns larger buffer)
scs.Read(test, 0, test.Length);
Assert.True(data.Skip(0x1000).Take(test.Length).SequenceEqual(test));

// After (works regardless of actual buffer size)
scs.Read(test, 0, 0x1000);
Assert.True(data.Skip(0x1000).Take(0x1000).SequenceEqual(test.Take(0x1000)));

This aligns with ArrayPool contract: rented buffers may be larger than requested and only the specified portion should be used.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

ArrayPool.Rent() can return buffers larger than requested. The tests were using test.Length (the actual buffer size) instead of the requested size (0x1000), causing failures on Windows where ArrayPool returns larger buffers than on Linux.

Fixed by:
- Using explicit size (0x1000) instead of test.Length in Read() calls
- Using test.Take(0x1000) instead of test when comparing arrays

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Async RAR functionality to the project Fix Windows test failures due to ArrayPool buffer sizing Oct 29, 2025
Copilot AI requested a review from adamhathcock October 29, 2025 13:43
@adamhathcock adamhathcock marked this pull request as ready for review October 29, 2025 14:01
@adamhathcock adamhathcock merged commit 77c8d31 into adam/async-rar-ai Oct 29, 2025
5 of 6 checks passed
@adamhathcock adamhathcock deleted the copilot/sub-pr-996 branch October 29, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants