forked from RobotWebTools/roslibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquaternion.test.js
65 lines (58 loc) · 2.1 KB
/
quaternion.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
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
var expect = require('chai').expect;
var ROSLIB = require('..');
describe('Quaternion', function() {
describe('creation', function() {
// Test fails. Claims returning Object.
// it('should return an object of the correct type', function() {
// var q = new ROSLIB.Quaternion();
// expect(q).to.be.a('ROSLIB.Quaternion');
// });
it('should return an identity quaternion when no params are specified', function() {
var q = new ROSLIB.Quaternion();
expect(q.x).to.equal(0);
expect(q.y).to.equal(0);
expect(q.z).to.equal(0);
expect(q.w).to.equal(1);
});
it('should return an identity quaternion when null is specified', function() {
var q = new ROSLIB.Quaternion({ x: null, y: null, z: null, w: null });
expect(q.x).to.equal(0);
expect(q.y).to.equal(0);
expect(q.z).to.equal(0);
expect(q.w).to.equal(1);
});
it('should return a quaternion matching the options hash', function() {
var q = new ROSLIB.Quaternion({ x: 1.1, y: 2.2, z: 3.3, w: 4.4 });
expect(q.x).to.equal(1.1);
expect(q.y).to.equal(2.2);
expect(q.z).to.equal(3.3);
expect(q.w).to.equal(4.4);
});
it('should return a quaternion matching the options', function() {
var q = new ROSLIB.Quaternion({ x: 1, y: 0, z: 0, w: 0 });
expect(q.x).to.equal(1);
expect(q.y).to.equal(0);
expect(q.z).to.equal(0);
expect(q.w).to.equal(0);
q = new ROSLIB.Quaternion({ x: 0, y: 1, z: 0, w: 0 });
expect(q.x).to.equal(0);
expect(q.y).to.equal(1);
expect(q.z).to.equal(0);
expect(q.w).to.equal(0);
q = new ROSLIB.Quaternion({ x: 0, y: 0, z: 1, w: 0 });
expect(q.x).to.equal(0);
expect(q.y).to.equal(0);
expect(q.z).to.equal(1);
expect(q.w).to.equal(0);
});
});
describe('conjugation', function() {
it('should conjugate itself', function() {
var q = new ROSLIB.Quaternion({ x: 1.1, y: 2.2, z: 3.3, w: 4.4 });
q.conjugate();
expect(q.x).to.equal(1.1*-1);
expect(q.y).to.equal(2.2*-1);
expect(q.z).to.equal(3.3*-1);
});
});
});