-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (31 loc) · 1.35 KB
/
test.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
32
33
34
35
36
37
38
var test = require("tape");
var arrayCompare = require('./index').arrayCompare;
var tolerantArrayCompare = require('./index').tolerantArrayCompare;
test("arrayCompare() should return false, when paramters don't have the same length.", function(t) {
t.equal(arrayCompare([2,3,4],[2]), false);
t.end();
});
test("arrayCompare() should return true, when comparing two empty arrays.", function(t) {
t.equal(arrayCompare([],[]), true);
t.end();
});
test("arrayCompare() should return false, when paramters don't have the same elements.", function(t) {
t.equal(arrayCompare([2,3,4],[2,3,5]), false);
t.end();
});
test("arrayCompare() should return true, when paramters are equal.", function(t){
t.equal(arrayCompare([2,3,4],[2,3,4]), true);
t.end();
});
test("tolerantArrayCompare() should return true, because arrays are equal.", function(t) {
t.equal(tolerantArrayCompare([1, 3, 6],[1, 3, 6], 0.1), true);
t.end();
});
test("tolerantArrayCompare() should return false, because arrays are different and tolerance is exceeded.", function(t) {
t.equal(tolerantArrayCompare([1, 3, 5],[1, 3, 6], 0.1), false);
t.end();
});
test("tolerantArrayCompare() should return true, because arrays are different but tolerance is not exceeded.", function(t) {
t.equal(tolerantArrayCompare([2.1, 3, 5],[2, 3, 5], 0.2), true);
t.end();
});