forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.js
More file actions
81 lines (63 loc) · 1.56 KB
/
test_utils.js
File metadata and controls
81 lines (63 loc) · 1.56 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module('sdk.tests.math.utils');
test("intToBytes", function () {
var i, b;
i = 0x11223344;
b = pc.math.intToBytes(i);
equal(b[0], 0x11);
equal(b[1], 0x22);
equal(b[2], 0x33);
equal(b[3], 0x44);
});
test("intToBytes32", function () {
var i, b;
i = 0x11223344;
b = pc.math.intToBytes32(i);
equal(b[0], 0x11);
equal(b[1], 0x22);
equal(b[2], 0x33);
equal(b[3], 0x44);
});
test("intToBytes24", function () {
var i, b;
i = 0x112233;
b = pc.math.intToBytes24(i);
equal(b[0], 0x11);
equal(b[1], 0x22);
equal(b[2], 0x33);
});
test("bytesToInt", function () {
var i,b;
b = [0xaa, 0xbb, 0xcc, 0xdd];
i = pc.math.bytesToInt(b);
equal(i, 0xaabbccdd);
});
test("bytesToInt32", function () {
var i,b;
b = [0xaa, 0xbb, 0xcc, 0xdd];
i = pc.math.bytesToInt32(b);
equal(i, 0xaabbccdd);
});
test("bytesToInt24", function () {
var i,b;
b = [0xaa, 0xbb, 0xcc];
i = pc.math.bytesToInt24(b);
equal(i, 0xaabbcc);
});
test("DEG_TO_RAD", function () {
var deg = 180;
equal(deg * pc.math.DEG_TO_RAD, Math.PI);
});
test("RAD_TO_DEG", function () {
var rad = Math.PI;
equal(rad * pc.math.RAD_TO_DEG, 180);
});
test("smoothstep", function () {
equal(pc.math.smoothstep(0, 10, 0), 0);
equal(pc.math.smoothstep(0, 10, 5), 0.5);
equal(pc.math.smoothstep(0, 10, 10), 1);
});
test("smootherstep", function () {
equal(pc.math.smootherstep(0, 10, 0), 0);
equal(pc.math.smootherstep(0, 10, 5), 0.5);
equal(pc.math.smootherstep(0, 10, 10), 1);
});