basic tests for a wider variety of files
This commit is contained in:
32
tests/components/MovementSystemUnitTest.cs
Normal file
32
tests/components/MovementSystemUnitTest.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.scenes.movement;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class MovementSystemUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void GroundedMovement_Accelerates_And_Applies_Gravity()
|
||||
{
|
||||
var move = new CGroundedMovement();
|
||||
move.RMovement = new RMovement(speed: 10.0f, acceleration: 1.0f, gravityModifier: 0.5f, targetHeight: 0.0f);
|
||||
move.WallInFrontRayCast = new RayCast3D();
|
||||
move.GlobalPosition = Vector3.Zero;
|
||||
|
||||
var inputs = new MovementInputs(
|
||||
Velocity: Vector3.Zero,
|
||||
TargetLocation: new Vector3(10, 0, 0),
|
||||
isOnFloor: false,
|
||||
gravity: Vector3.Down * 9.8f,
|
||||
delta: 1.0
|
||||
);
|
||||
|
||||
var v = move.ComputeVelocity(inputs);
|
||||
|
||||
AssertVector(v).IsEqualApprox(new Vector3(10, -4.9f, 0), new Vector3(0.0001f, 0.0001f, 0.0001f));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user