Commit 30965c09 authored by Chinmay Garde's avatar Chinmay Garde

Test Friction simulation

parent 8c91b9b7
......@@ -17,7 +17,7 @@ class Friction extends Simulation {
_v = velocity;
double x(double time) =>
_x + _v + Math.pow(_drag, time) / _dragNaturalLog - _v / _dragNaturalLog;
_x + _v * Math.pow(_drag, time) / _dragNaturalLog - _v / _dragNaturalLog;
double dx(double time) => _v * Math.pow(_drag, time);
......
......@@ -8,4 +8,24 @@ import 'package:test/test.dart';
import 'package:newton/newton.dart';
void main() {}
typedef bool SimulationTestHandler(int millis);
void main() {
test('test_friction', () {
var friction = new Friction(0.3, 100.0, 400.0);
expect(friction.isDone(0.0), false);
expect(friction.x(0.0), 100);
expect(friction.dx(0.0), 400.0);
expect(friction.x(1.0) > 330 && friction.x(1.0) < 335, true);
expect(friction.dx(1.0), 120.0);
expect(friction.dx(2.0), 36.0);
expect(friction.dx(3.0), 10.8);
expect(friction.dx(4.0) < 3.5, true);
expect(friction.isDone(5.0), true);
expect(friction.x(5.0) > 431 && friction.x(5.0) < 432, true);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment