flutter_flutter/testing/dart/text_test.dart
MH Johnson 3796d98918
[ui] Add null check in FontWeight.lerp (#8274)
* Add null check in FontWeight.lerp

* Add Unit tests for FontWeight.lerp
2019-04-01 21:56:19 -04:00

28 lines
821 B
Dart

// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:test/test.dart';
void main() {
group('FontWeight.lerp', () {
test('works with non-null values', () {
expect(FontWeight.lerp(FontWeight.w400, FontWeight.w600, .5), equals(FontWeight.w500));
});
test('returns null if a and b are null', () {
expect(FontWeight.lerp(null, null, 0), isNull);
});
test('returns FontWeight.w400 if a is null', () {
expect(FontWeight.lerp(null, FontWeight.w400, 0), equals(FontWeight.w400));
});
test('returns FontWeight.w400 if b is null', () {
expect(FontWeight.lerp(FontWeight.w400, null, 1), equals(FontWeight.w400));
});
});
}