-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1042 from fabulous-dev/fix-combinemut-error
When combining 2 arrays, array B should be reused but array A was passed instead
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Fabulous.Tests | ||
|
||
open System | ||
open Fabulous.StackAllocatedCollections | ||
open NUnit.Framework | ||
open Fabulous | ||
|
||
[<TestFixture>] | ||
type ``Array tests``() = | ||
[<Test>] | ||
member _.``MutStackArray1.combineMut reuses array B if can fit all data``() = | ||
let arrB = Array.zeroCreate 7 | ||
|
||
let a = MutStackArray1.Many((2us, Array.zeroCreate 4)) | ||
let b = MutStackArray1.Many((5us, arrB)) | ||
let c = MutStackArray1.combineMut(&a, b) | ||
let cOpt = MutStackArray1.toArraySlice &c | ||
let struct (usedC, arrC) = cOpt.Value | ||
|
||
// We should have the same number of used items | ||
Assert.AreEqual(7us, usedC) | ||
|
||
// Reference should be equal to arrB since the array was reused | ||
Assert.True(Object.ReferenceEquals(arrC, arrB)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters