public void AllTrueTest(bool[] source, bool expected) { var list = new VSArray <bool>(source); var value = list.AllTrue(); Assert.That(value, Is.EqualTo(expected)); }
public void SetElementThrowTest() { var list = new VSArray <int>(new[] { 1, 2, 3 }); Assert.Throws(typeof(ArgumentOutOfRangeException), () => list.SetElement(-1, 0)); Assert.Throws(typeof(ArgumentOutOfRangeException), () => list.SetElement(8, 0)); }
public void StandardDeviationTest() { var list = new VSArray <float>(new float[] { 2, 4, 4, 4, 5, 5, 7, 9 }); var value = list.StandardDeviation(); Assert.That(value, Is.EqualTo(2.0f)); }
static void DebugLog <T>(VSArray <T> list) { for (int i = 0; i < list.GetElementCount(); i++) { Debug.Log("[" + i + "]: " + list[i]); } }
public void CullElements(int[] source, bool[] cull, int[] expected) { var list = new VSArray <int>(source); list.CullElements(cull.ToVSArray()); Assert.That(list, Is.EqualTo(expected.ToVSArray())); }
public void GetLastIndexOfElementTest() { var list = new VSArray <int>(new[] { 0, 1, 2, 3, 4, 3, 6 }); Assert.That(list.GetLastIndexOfElement(3), Is.EqualTo(5)); Assert.That(list.GetLastIndexOfElement(4), Is.EqualTo(4)); }
public void MaximumTestI() { var list = new VSArray <int>(new[] { 1, 0, 4, 3, 2 }); var value = list.Maximum(); Assert.That(value, Is.EqualTo(4)); }
public void TakeEveryThrowTest() { var list = new VSArray <int>(); Assert.Throws(typeof(ArgumentException), () => list.GetTakeEvery(0)); Assert.Throws(typeof(ArgumentException), () => list.GetTakeEvery(-1)); }
public void ContainElementTest() { var list = new VSArray <int>(new[] { 0, 1, 2, 3, 4, 5, 6 }); Assert.That(list.ContainsElement(3), Is.EqualTo(true)); Assert.That(list.ContainsElement(7), Is.EqualTo(false)); }
public void MaximumTestF() { var list = new VSArray <float>(new[] { 1.0f, 0.0f, 4.0f, 3.0f, 2.0f }); var value = list.Maximum(); Assert.That(value, Is.EqualTo(4.0f)); }
public void VarianceTest() { var list = new VSArray <float>(new float[] { 2, 4, 4, 4, 5, 5, 7, 9 }); var value = list.Variance(); Assert.That(value, Is.EqualTo(4.0f)); }
public void GetCopyTest() { var list = new VSArray <int>(new[] { 0, 1, 2, 3, 0, 0, 4, 5 }); var list2 = list.GetCopy(); Assert.That(list, Is.EqualTo(list2)); }
public void AverageTest() { var list = new VSArray <float>(new[] { 1.0f, 0.0f, 4.0f, 3.0f, 2.0f }); var value = list.Average(); Assert.That(value, Is.EqualTo(2.0f)); }
public void SwapElementsTest(int[] source, int index0, int index1, int[] expected) { var list = new VSArray <int>(source); list.SwapElements(index0, index1); Assert.That(list, Is.EqualTo(expected.ToVSArray())); }
public void ClearTest() { var list = new VSArray <int>(new[] { 0, 1, 2, 3, 4, 5, 6 }); Assert.That(list.GetElementCount(), Is.EqualTo(7)); list.Clear(); Assert.That(list.GetElementCount(), Is.EqualTo(0)); }
public void SecondElementTestThrow() { var list = new VSArray <int>(); Assert.Throws(typeof(ArgumentOutOfRangeException), () => list.SecondElement()); list.AddElement(2); Assert.Throws(typeof(ArgumentOutOfRangeException), () => list.SecondElement()); }
public void RemoveElementAtTest(int[] source, int index, int[] expected) { var list = new VSArray <int>(source); Assert.That(list.GetElementCount(), Is.EqualTo(source.Length)); list.RemoveElementAt(index); Assert.That(list, Is.EqualTo(expected.ToVSArray())); }
public void RemoveElementTest() { var list = new VSArray <int>(new[] { 0, 1, 2, 3, 0, 0, 4, 5 }); Assert.That(list.GetElementCount(), Is.EqualTo(8)); list.RemoveElement(0); Assert.That(list.GetElementCount(), Is.EqualTo(7)); }
public void IsEmptyTest() { var listA = new VSArray <int>(new[] { 0, 1, 2, 3, 4 }); Assert.That(listA.IsEmpty(), Is.EqualTo(false)); var listB = new VSArray <int>(); Assert.That(listB.IsEmpty(), Is.EqualTo(true)); }
public void AddElementTest() { var list = new VSArray <char>(new[] { 'a', 'b', 'c', 'd', 'e' }); Assert.That(list.GetElementCount(), Is.EqualTo(5)); list.AddElement('f'); Assert.That(list.GetElementCount(), Is.EqualTo(6)); Assert.That(list.GetElement(5), Is.EqualTo('f')); }
public void SetElementTest() { var list = new VSArray <int>(new[] { 1, 2, 3, 4, 5, 6 }); list.SetElement(0, 10); Assert.That(list.GetElement(0), Is.EqualTo(10)); list.SetElement(3, 10); Assert.That(list.GetElement(3), Is.EqualTo(10)); }
public static VSArray <Vector3> MakeNormalized(VSArray <Vector3> array) { var newArray = new VSArray <Vector3>(array.Count); foreach (var element in array) { newArray.Add(element.normalized); } return(newArray); }
public void SumTestV() { var list = new VSArray <Vector3>(); list.Add(new Vector3(0, 0, 0)); list.Add(new Vector3(1, 2, 3)); list.Add(new Vector3(2, 4, 6)); list.Add(new Vector3(3, 6, 9)); list.Add(new Vector3(4, 8, 12)); var value = list.Sum(); Assert.That(value, Is.EqualTo(new Vector3(10, 20, 30))); }
public void ShiftElementsTest(int[] source, int amount, int[] expected) { var list1 = new VSArray <int>(source); // Create new list, don't modify original var list2 = list1.GetShiftElements(amount); Assert.That(list1, Is.EqualTo(source.ToVSArray())); Assert.That(list2, Is.EqualTo(expected.ToVSArray())); // Modify original (in-place) list1.ShiftElements(amount); Assert.That(list1, Is.EqualTo(expected.ToList())); Assert.That(list1, Is.EqualTo(list2)); }
public static Vector3 Sum(this VSArray <Vector3> array) { if (array == null) { throw new ArgumentNullException(nameof(array)); } Vector3 sum = Vector3.zero; foreach (var value in array.elements) { sum += value; } return(sum); }
public static VSArray <int> MakeStep(int elementCount, int minValue = 0, int step = 1) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } var array = new VSArray <int>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(minValue); minValue += step; } return(array); }
public static VSArray <int> MakeRandomInteger(int elementCount, int minRange = 0, int maxRange = 1, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } Random.InitState(seed); var array = new VSArray <int>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(Random.Range(minRange, maxRange)); } return(array); }
public static VSArray <Quaternion> MakeRandomQuaternion(int elementCount, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } Random.InitState(seed); var array = new VSArray <Quaternion>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(Random.rotationUniform); } return(array); }
public static VSArray <float> MakeFibonacci(int elementCount) { if (elementCount < 2) { throw new ArgumentException("Element Count must be greater or equal to 2.", nameof(elementCount)); } var fibonacci = new VSArray <float>(elementCount); fibonacci.Add(1); fibonacci.Add(1); for (var i = 2; i < elementCount; i++) { fibonacci.Add(fibonacci[i - 1] + fibonacci[i - 2]); } return(fibonacci); }
public void IntersectionTest(int[] a, int[] b, int[] expected) { var listA = new VSArray <int>(a); var listB = new VSArray <int>(b); // Create new list, don't modify original var list2 = listA.Intersect(listB); Assert.That(listA, Is.EqualTo(a.ToVSArray())); Assert.That(listB, Is.EqualTo(b.ToVSArray())); Assert.That(list2, Is.EqualTo(expected.ToVSArray())); // Modify original (in-place) listA.IntersectWith(listB); Assert.That(listA, Is.EqualTo(expected.ToVSArray())); Assert.That(listA, Is.EqualTo(list2)); }