public void TargetPositionsDisposed() { NativeArray <Vector3> targetPositions = new NativeArray <Vector3>(targets, Allocator.Temp); NativeArray <float> Weights = new NativeArray <float>(_weights, Allocator.Temp); DotToVecJob job = new DotToVecJob() { targets = targetPositions, scaled = scaled, my_position = position, range = range, weight = weight, angle = angle, invertScale = invertScale, axis = axis, Weights = Weights, direction = direction }; // compute job.Execute(); targetPositions.Dispose(); // check result Assert.AreEqual(false, targetPositions.IsCreated); Weights.Dispose(); }
public void StandardMapYAxis() { NativeArray <Vector3> targetPositions = new NativeArray <Vector3>(targets, Allocator.Temp); NativeArray <float> Weights = new NativeArray <float>(_weights, Allocator.Temp); DotToVecJob job = new DotToVecJob() { targets = targetPositions, scaled = scaled, my_position = position, range = range, weight = weight, angle = angle, invertScale = invertScale, axis = axis, Weights = Weights, direction = direction }; // compute job.Execute(); // check result float[] expected = { 1f, 0f, -1f, 0f }; Assert.AreEqual(expected[0], Weights[0], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[1], Weights[1], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[2], Weights[2], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[3], Weights[3], TestUtilities.DOTPRODTOLERANCE); targetPositions.Dispose(); Weights.Dispose(); }
public void RangeYAxis() { // ------------------- Out of Range ------------------- range = 10; targets = new Vector3[] { new Vector3(0, 0, 15) }; NativeArray <Vector3> targetPositions = new NativeArray <Vector3>(targets, Allocator.Temp); NativeArray <float> Weights = new NativeArray <float>(_weights, Allocator.Temp); DotToVecJob job = new DotToVecJob() { targets = targetPositions, scaled = scaled, my_position = position, range = range, weight = weight, angle = angle, invertScale = invertScale, axis = axis, Weights = Weights, direction = direction }; // compute job.Execute(); // check result float[] expected = { 0f, 0f, 0f, 0f }; Assert.AreEqual(expected[0], Weights[0], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[1], Weights[1], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[2], Weights[2], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[3], Weights[3], TestUtilities.DOTPRODTOLERANCE); targetPositions.Dispose(); // ------------------- In Range ------------------- targets = new Vector3[] { new Vector3(0, 0, 8) }; NativeArray <Vector3> newTargetPositions = new NativeArray <Vector3>(targets, Allocator.Temp); job = new DotToVecJob() { targets = newTargetPositions, scaled = scaled, my_position = position, range = range, weight = weight, angle = angle, invertScale = invertScale, axis = axis, Weights = Weights, direction = direction }; // compute job.Execute(); // check result expected = new float[] { 1f, 0f, -1f, 0f }; //Assert.AreEqual(expected[0], Weights[0], TestUtilities.DOTPRODTOLERANCE)); Assert.AreEqual(expected[0], Weights[0]); Assert.AreEqual(expected[1], Weights[1], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[2], Weights[2], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[3], Weights[3], TestUtilities.DOTPRODTOLERANCE); newTargetPositions.Dispose(); // ------------------- Same Position ------------------- targets = new Vector3[] { new Vector3(0, 0, 0) }; NativeArray <Vector3> targetOnMe = new NativeArray <Vector3>(targets, Allocator.Temp); job = new DotToVecJob() { targets = targetOnMe, scaled = scaled, my_position = position, range = range, weight = weight, angle = angle, invertScale = invertScale, axis = axis, Weights = Weights, direction = direction }; job.Execute(); expected = new float[] { 0, 0, 0, 0 }; Assert.AreEqual(expected[0], Weights[0], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[1], Weights[1], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[2], Weights[2], TestUtilities.DOTPRODTOLERANCE); Assert.AreEqual(expected[3], Weights[3], TestUtilities.DOTPRODTOLERANCE); targetOnMe.Dispose(); Weights.Dispose(); }