-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquickSort_tests.js
31 lines (24 loc) · 1.02 KB
/
quickSort_tests.js
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
(function () {
var unitTests = {
quickSort: function () {
// assertEqual(Object.prototype.toString.call(quickSort([0])), '[object Array]');
// assertEqual(quickSort([0]).toString(), [0].sort().toString());
// assertEqual(quickSort([1,0]).toString(), [1,0].sort().toString());
// assertEqual(quickSort([4,1,3]).toString(), [4,1,3].sort().toString());
assertEqual(quickSort([1,2,3,4,5]).toString(), [1,2,3,4,5].sort().toString());
assertEqual(quickSort([4,9,1,5,7,8,3,5,9]).toString(), [4,9,1,5,7,8,3,5,9].sort().toString());
}
};
var unitTestsMethods = Object.keys(unitTests);
for (var i = 0; i < unitTestsMethods.length; i++) {
try {
unitTests[unitTestsMethods[i]]();
console.log(unitTestsMethods[i] + ' OK');
}
catch (error) {
if (error) {
console.log(unitTestsMethods[i] + ' failed.\n' + error);
}
}
};
} ());