1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2015 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "libpspp/compiler.h"
26 #include "math/chart-geometry.h"
33 dump_scale (const double low
, const double interval
, int n_ticks
)
37 for (i
= 0; i
<= n_ticks
; ++i
)
39 printf ("Tick %d: %g\n", i
, tick
);
47 test_range (double low
, double high
)
53 chart_get_scale (high
, low
,
54 &lower
, &interval
, &n_ticks
);
56 if ((high
- low
) < 10 * DBL_MIN
){
57 assert (n_ticks
== 0);
58 assert (lower
== low
);
59 assert (interval
<= 10 * DBL_MIN
);
64 assert (n_ticks
<= 10);
67 printf("%s: high: %lg, low %lg, interval: %lg, nticks: %d\n",
68 __FUNCTION__
, high
, low
, interval
, n_ticks
);
69 dump_scale (lower
, interval
, n_ticks
);
72 if ((high
- low
) > 10 * DBL_MIN
) {
73 assert (lower
<= low
);
74 assert (lower
+ interval
> low
);
75 assert (lower
+ n_ticks
* interval
< high
);
76 assert (lower
+ (n_ticks
+ 1) * interval
>= high
);
82 main (int argc UNUSED
, char **argv UNUSED
)
89 test_range (-0.2, 11);
90 test_range (-10, 0.2);
91 test_range (-10, -0.2);
92 test_range (-10000, 10003);
93 test_range (50042,50053);
94 test_range (-50010, -49999);
95 test_range (0.000100002, 0.000100010);
97 test_range (102, 50030);
98 test_range (0.00102, 0.0050030);