blob: a878b202e131a3d78afa1a777e392d2582742aaa [file] [log] [blame]
/*
* Copyright (c) 2017, 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 void sort([int compare(E a, E b)])
* ...
* The default List implementations use Comparable.compare if compare is
* omitted.
* @description Checks sorting various integer arrays with Comparable.compare.
* @author ngl@unipro.ru
*/
import "dart:typed_data";
import "../../../Utils/expect.dart";
void check(List<int> list, List<int> expected) {
var actual = new Int8List.fromList(list);
actual.sort();
Expect.listEquals(expected, actual);
}
main() {
check([], []);
check([1], [1]);
check([1, 2], [1, 2]);
check([1, 2, 4, 3, 5, 6], [1, 2, 3, 4, 5, 6]);
check([2, 1, 4, 3, 6, 5], [1, 2, 3, 4, 5, 6]);
check([6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6]);
check([9, 9, 1, 2, 3, 0, 3, 2, 4, 5, 7, 7, 6, 1, 0, 4, 8, 8, 5, 6],
[0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]);
}