1
|
|
|
describe("The arb.js test suite", function(){
|
2
|
|
|
var arb = require("../../src/index.js");
|
3
|
|
|
|
4
|
|
|
var mulTestPair = ["1234567890", "9876543210"];
|
5
|
|
|
var mulTestAnswer = "12193263111263526900.0";
|
6
|
|
|
var addTestPair = ["1234567890", "9876543210"];
|
7
|
|
|
var addTestAnswer = "11111111100.0";
|
8
|
|
|
var subTestPair = ["1234567890", "9876543210"];
|
9
|
|
|
var subTestAnswer = "-8641975320.0";
|
10
|
|
|
var divTestPair = ["1234567890", "9876543210"];
|
11
|
|
|
var divTestAnswer = "0.1249999988609375000";
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
describe("Addition tests", function(){
|
15
|
|
|
it("should work properly on addition", function(){
|
16
|
|
|
//console.info("Running Addition Test...");
|
17
|
|
|
expect(arb(addTestPair[0]).add(addTestPair[1]).value).toBe(addTestAnswer);
|
18
|
|
|
});
|
19
|
|
|
});
|
20
|
|
|
|
21
|
|
|
describe("Subtraction tests", function(){
|
22
|
|
|
//console.info("Running Subtraction Test...");
|
23
|
|
|
it("should work properly on subtraction", function(){
|
24
|
|
|
expect(arb(subTestPair[0]).sub(subTestPair[1]).value).toBe(subTestAnswer);
|
25
|
|
|
});
|
26
|
|
|
});
|
27
|
|
|
|
28
|
|
|
describe("Multiplication tests", function(){
|
29
|
|
|
//console.info("Running multiplication Test...");
|
30
|
|
|
it("should work properly on multiplication", function(){
|
31
|
|
|
expect(arb(mulTestPair[0]).mul(mulTestPair[1]).value).toBe(mulTestAnswer);
|
32
|
|
|
});
|
33
|
|
|
});
|
34
|
|
|
|
35
|
|
|
describe("Division tests", function(){
|
36
|
|
|
//console.info("Running Division Test...");
|
37
|
|
|
it("should work properly on division", function(){
|
38
|
|
|
expect(arb(divTestPair[0]).div(divTestPair[1]).value.substr(0, 21)).toBe(divTestAnswer);
|
39
|
|
|
expect(arb("1").div("0.0001").value).toBe("10000.0");
|
40
|
|
|
expect(arb("1").div("89").value.substr(0, 22)).toBe("0.01123595505617977528");
|
41
|
|
|
});
|
42
|
|
|
});
|
43
|
|
|
|
44
|
|
|
describe("Equal tests", function(){
|
45
|
|
|
it("should work properly on equal", function(){
|
46
|
|
|
expect(arb("12345").eq("12345.0")).toBe(true);
|
47
|
|
|
});
|
48
|
|
|
});
|
49
|
|
|
|
50
|
|
|
describe("Less than tests", function(){
|
51
|
|
|
it("should work properly", function(){
|
52
|
|
|
expect(arb("12345.0").lt("12346")).toBe(true);
|
53
|
|
|
expect(arb("-12345.0").lt("12345.0")).toBe(true);
|
54
|
|
|
});
|
55
|
|
|
});
|
56
|
|
|
|
57
|
|
|
describe("Greater than tests", function(){
|
58
|
|
|
it("should work properly", function(){
|
59
|
|
|
expect(arb("123465365.0").gt("12346")).toBe(true);
|
60
|
|
|
expect(arb("-2345827389.0").gt("-1239999999945.0")).toBe(true);
|
61
|
|
|
});
|
62
|
|
|
});
|
63
|
|
|
|
64
|
|
|
describe("Less than or equal tests", function(){
|
65
|
|
|
it("should work properly", function(){
|
66
|
|
|
expect(arb("12345.0").lte("12346")).toBe(true);
|
67
|
|
|
expect(arb("12345.0").lte("12345.0")).toBe(true);
|
68
|
|
|
});
|
69
|
|
|
});
|
70
|
|
|
|
71
|
|
|
describe("Greater than or equal tests", function(){
|
72
|
|
|
it("should work properly", function(){
|
73
|
|
|
expect(arb("12346.0").gte("12346")).toBe(true);
|
74
|
|
|
expect(arb("9112345.0").gte("12345.0")).toBe(true);
|
75
|
|
|
});
|
76
|
|
|
});
|
77
|
|
|
});
|
78
|
|
|
|