blob: 13fbe793f67bb8ed0a8b3a8ec76c6a0f4b0dfbcc [file] [log] [blame]
// Copyright (c) 2016, 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.
/// @assertion int checkValidRange(int start, int end, int length,
/// [String startName, String endName, String message])
/// ...
/// Returns the actual end value, which is length if end is null, and end
/// otherwise.
/// ...
/// @description Checks that this method returns the actual end value, which is
/// length if end is null, and end otherwise
/// @author
import "../../../Utils/expect.dart";
check(int start, int length) {
try {
RangeError.checkValidRange(start, null, length);"RangeError expected");
} on RangeError catch (e) {
Expect.equals(0, e.start);
Expect.equals(length, e.end);
Expect.equals(start, e.invalidValue);
} catch (e) {"Wrong exception type $e");
main() {
Expect.equals(3, RangeError.checkValidRange(0, 3, 5));
Expect.equals(0, RangeError.checkValidRange(0, 0, 1));
Expect.equals(0, RangeError.checkValidRange(0, 0, 0));
Expect.equals(5, RangeError.checkValidRange(0, null, 5));
Expect.equals(5, RangeError.checkValidRange(3, null, 5));
Expect.equals(5, RangeError.checkValidRange(5, null, 5));