utils_test.dart 688 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/physics.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('nearEquals', () {
    expect(nearEqual(double.infinity, double.infinity, 0.1), isTrue);
    expect(nearEqual(double.negativeInfinity, double.negativeInfinity, 0.1), isTrue);

    expect(nearEqual(double.infinity, double.negativeInfinity, 0.1), isFalse);

    expect(nearEqual(0.1, 0.11, 0.001), isFalse);
    expect(nearEqual(0.1, 0.11, 0.1), isTrue);
    expect(nearEqual(0.1, 0.1, 0.0000001), isTrue);
  });
}