-
-
Notifications
You must be signed in to change notification settings - Fork 488
Expand file tree
/
Copy pathbucket_sort_test.dart
More file actions
46 lines (39 loc) · 1.25 KB
/
bucket_sort_test.dart
File metadata and controls
46 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import 'package:test/test.dart';
import '../../sort/bucket_sort.dart';
void main() {
test('Test case 1', () {
List<double> arr = [0.42, 0.32, 0.33, 0.52, 0.37, 0.47, 0.51];
bucketSort(arr);
expect(arr, orderedEquals([0.32, 0.33, 0.37, 0.42, 0.47, 0.51, 0.52]));
});
test('Test case 2', () {
List<double> arr = [5.0, 4.0, 3.0, 2.0, 1.0];
bucketSort(arr);
expect(arr, orderedEquals([1.0, 2.0, 3.0, 4.0, 5.0]));
});
test('Test case 3', () {
List<double> arr = [1.1, 2.2, 3.3, 4.4, 5.5];
bucketSort(arr);
expect(arr, orderedEquals([1.1, 2.2, 3.3, 4.4, 5.5]));
});
test('Test case 4 (Empty List)', () {
List<double> arr = [];
bucketSort(arr);
expect(arr, orderedEquals([]));
});
test('Test case 5 (Already Sorted)', () {
List<double> arr = [1.0, 2.0, 3.0, 4.0, 5.0];
bucketSort(arr);
expect(arr, orderedEquals([1.0, 2.0, 3.0, 4.0, 5.0]));
});
test('Test case 6 (Reverse Sorted)', () {
List<double> arr = [5.0, 4.0, 3.0, 2.0, 1.0];
bucketSort(arr);
expect(arr, orderedEquals([1.0, 2.0, 3.0, 4.0, 5.0]));
});
test('Test case 7 (All Equal)', () {
List<double> arr = [2.0, 2.0, 2.0, 2.0, 2.0];
bucketSort(arr);
expect(arr, orderedEquals([2.0, 2.0, 2.0, 2.0, 2.0]));
});
}