mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
32 lines
863 B
Dart
32 lines
863 B
Dart
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
library simple_physics.test;
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
import 'package:newton/newton.dart';
|
|
|
|
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);
|
|
});
|
|
}
|