forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplineSpec.js
62 lines (51 loc) · 1.93 KB
/
SplineSpec.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
/*global defineSuite*/
defineSuite([
'Core/Spline',
'Core/Cartesian3',
'Core/HermiteSpline'
], function(
Spline,
Cartesian3,
HermiteSpline) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
it('contructor throws', function() {
expect(function() {
return new Spline();
}).toThrowDeveloperError();
});
it('findTimeInterval throws without a time', function() {
var spline = HermiteSpline.createNaturalCubic({
points : [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y],
times : [0.0, 1.0, 2.0]
});
expect(function() {
spline.findTimeInterval();
}).toThrowDeveloperError();
});
it('findTimeInterval throws when time is out of range', function() {
var spline = HermiteSpline.createNaturalCubic({
points : [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y],
times : [0.0, 1.0, 2.0]
});
expect(function() {
spline.findTimeInterval(4.0);
}).toThrowDeveloperError();
});
it('findTimeInterval', function() {
var spline = HermiteSpline.createNaturalCubic({
points : [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y, Cartesian3.UNIT_Z],
times : [0.0, 1.0, 2.0, 4.0]
});
var times = spline.times;
expect(spline.findTimeInterval(times[0])).toEqual(0);
// jump forward
expect(spline.findTimeInterval(times[1])).toEqual(1);
// jump backward
expect(spline.findTimeInterval(times[0], 1)).toEqual(0);
// jump far forward
expect(spline.findTimeInterval(times[times.length - 2], 0)).toEqual(times.length - 2);
// jump far back
expect(spline.findTimeInterval(times[0], times.length - 1)).toEqual(0);
});
});