Smooth plotter using bezier curves.
[dygraphs.git] / auto_tests / tests / smooth_plotter.js
CommitLineData
c36a62c2
DV
1/**
2 * @fileoverview Tests for the smooth (bezier curve) plotter.
3 *
4 * @author danvdk@gmail.com (Dan Vanderkam)
5 */
6var smoothPlotterTestCase = TestCase("smooth-plotter");
7
8var getControlPoints = smoothPlotter._getControlPoints;
9
10smoothPlotterTestCase.prototype.setUp = function() {
11};
12
13smoothPlotterTestCase.prototype.tearDown = function() {
14};
15
16smoothPlotterTestCase.prototype.testNoSmoothing = function() {
17 var lastPt = {x: 10, y: 0},
18 pt = {x: 11, y: 1},
19 nextPt = {x: 12, y: 0},
20 alpha = 0;
21
22 assertEquals([11, 1, 11, 1], getControlPoints(lastPt, pt, nextPt, alpha));
23};
24
25smoothPlotterTestCase.prototype.testHalfSmoothing = function() {
26 var lastPt = {x: 10, y: 0},
27 pt = {x: 11, y: 1},
28 nextPt = {x: 12, y: 0},
29 alpha = 0.5;
30
31 assertEquals([10.5, 1, 11.5, 1], getControlPoints(lastPt, pt, nextPt, alpha));
32}
33
34smoothPlotterTestCase.prototype.testExtrema = function() {
35 var lastPt = {x: 10, y: 0},
36 pt = {x: 11, y: 1},
37 nextPt = {x: 12, y: 1},
38 alpha = 0.5;
39
40 assertEquals([10.5, 0.75, 11.5, 1.25],
41 getControlPoints(lastPt, pt, nextPt, alpha, true));
42
43 assertEquals([10.5, 1, 11.5, 1],
44 getControlPoints(lastPt, pt, nextPt, alpha, false));
45}