-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CommandBuffer Tests And Fixes (#160)
* - Added some more tests covering the `CommandBuffer`. Fixed a bug in `Create` method, sometimes assigning duplicate IDs. - Removed all conditional access in `Playback` and `Dispose`, those things are never null. - Added ArrayExtensions tests. * Simplified ID generation
- Loading branch information
1 parent
2e37009
commit c7f59a9
Showing
3 changed files
with
188 additions
and
19 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,59 @@ | ||
using Arch.Core.Extensions.Internal; | ||
|
||
namespace Arch.Tests.Extensions; | ||
|
||
[TestFixture] | ||
public class ArrayExtensionsTests | ||
{ | ||
[Test] | ||
public void Add_InRange() | ||
{ | ||
var arr = new[] { 1, 2, 3 }; | ||
arr.Add(0, 7); | ||
|
||
CollectionAssert.AreEqual(new[] { 7, 2, 3 }, arr); | ||
} | ||
|
||
[Test] | ||
public void Add_OutOfRange() | ||
{ | ||
var arr = new[] { 1, 2, 3 }; | ||
arr = arr.Add(3, 7); | ||
|
||
// The array might be any size now. | ||
// All we need to check if that the first 4 elements are correct. | ||
CollectionAssert.AreEqual(new[] { 1, 2, 3, 7 }, arr.Take(4)); | ||
} | ||
|
||
[Test] | ||
public void Add_FarOutOfRange() | ||
{ | ||
var arr = new[] { 1, 2, 3 }; | ||
arr = arr.Add(30, 7); | ||
|
||
// The array might be any size now. | ||
// All we need to check if that the first 3 elements are correct and the 30th is 7. | ||
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, arr.Take(3)); | ||
Assert.That(arr[30], Is.EqualTo(7)); | ||
} | ||
|
||
[Test] | ||
public void Add_VeryFarOutOfRange() | ||
{ | ||
var arr = new[] { 1, 2, 3 }; | ||
arr = arr.Add(3000, 7); | ||
|
||
// The array might be any size now. | ||
// All we need to check if that the first 3 elements are correct and the 30th is 7. | ||
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, arr.Take(3)); | ||
Assert.That(arr[3000], Is.EqualTo(7)); | ||
} | ||
|
||
[Test] | ||
public void Add_NegativeIndex() | ||
{ | ||
var arr = new[] { 1, 2, 3 }; | ||
|
||
Assert.Throws<ArgumentOutOfRangeException>(() => arr.Add(-1, 7)); | ||
} | ||
} |
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