blob: db0a8a3e753b899f1485e1edcf315231e25a755b [file] [edit]
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/utilities/extensions/object.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(NullableObjectExtensionTest);
});
}
@reflectiveTest
class NullableObjectExtensionTest {
test_tryCast_int() {
expect(0.tryCast<int>(), 0);
expect(0.tryCast<num>(), 0);
expect(0.tryCast<Object>(), 0);
expect(0.tryCast<String>(), isNull);
}
test_tryCast_null() {
expect(null.tryCast<Object>(), isNull);
expect(null.tryCast<int>(), isNull);
}
}