This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New array Extension plus tests (#461)
* * Added new "InitialiseArray" array extension to set all values of an array to a new value, including Tests * Added null check on Array AddItem Fixed license in Core test 2 * Update XRTK-Core/Packages/com.xrtk.core/Extensions/ArrayExtensions.cs Co-Authored-By: Stephen Hodgson <StephenHodgson@users.noreply.github.com> * Applied review patches Co-authored-by: Stephen Hodgson <StephenHodgson@users.noreply.github.com>
- Loading branch information
1 parent
87b479c
commit 6c7ada8
Showing
4 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
XRTK-Core/Assets/XRTK.Tests/Core/TestFixture_02_MixedRealityToolkitUtilityTests.cs
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
58 changes: 58 additions & 0 deletions
58
XRTK-Core/Assets/XRTK.Tests/Core/TestFixture_03_ExtensionsTests.cs
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,58 @@ | ||
// Copyright (c) XRTK. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using NUnit.Framework; | ||
using UnityEngine; | ||
using XRTK.Extensions; | ||
|
||
namespace XRTK.Tests.Core | ||
{ | ||
public class TestFixture_03_ExtensionsTests | ||
{ | ||
[Test] | ||
public void Test_01_Array_AddItem_Extension() | ||
{ | ||
Vector2[] testArray = null; | ||
Vector2[] newArray = null; | ||
try | ||
{ | ||
newArray = testArray.AddItem(Vector2.zero); | ||
} | ||
catch { } | ||
|
||
Assert.IsNotNull(newArray); | ||
|
||
testArray = new Vector2[5]; | ||
newArray = testArray.AddItem(Vector2.one); | ||
|
||
Assert.IsTrue(newArray[newArray.Length - 1] == Vector2.one); | ||
Assert.IsTrue(newArray.Length > testArray.Length); | ||
Assert.IsTrue(newArray.Length - testArray.Length == 1); | ||
} | ||
|
||
[Test] | ||
public void Test_02_Array_InitialiseArray_Extension() | ||
{ | ||
Vector2[] testArray = null; | ||
Vector2[] newArray = null; | ||
try | ||
{ | ||
newArray = testArray.InitialiseArray(Vector2.one); | ||
} | ||
catch { } | ||
|
||
Assert.IsNotNull(newArray); | ||
Assert.IsTrue(newArray.Length == 1); | ||
Assert.IsTrue(newArray[0] == Vector2.one); | ||
|
||
testArray = new Vector2[5]; | ||
for (int i = 0; i < testArray.Length; i++) | ||
{ | ||
testArray[i] = Vector2.one; | ||
} | ||
newArray = testArray.InitialiseArray(Vector2.zero); | ||
|
||
Assert.IsTrue(newArray[0] == Vector2.zero); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
XRTK-Core/Assets/XRTK.Tests/Core/TestFixture_03_ExtensionsTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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