File: limits_round.t

package info (click to toggle)
pdl 1%3A2.4.7%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,128 kB
  • ctags: 5,821
  • sloc: perl: 26,328; fortran: 13,113; ansic: 9,378; makefile: 71; sh: 50; sed: 6
file content (68 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download | duplicates (4)
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

use Test::More;

BEGIN {
  eval "use PDL::Slatec;";
  if ( !$@ ) {
    eval "use PDL::Graphics::Limits;";
    plan tests => 37;
  } else {
    plan skip_all => 'PDL::Slatec not available';
  }
};

*round_pow = \&PDL::Graphics::Limits::round_pow;

@round_tests =
 ( 
  [ -100, -200, -50 ],
  [ -11, -20, -10 ],
  [ -10, -20, -5 ],
  [ -6, -10, -5 ],
  [ -5, -10, -2 ],
  [ -3, -5, -2 ],
  [ -2, -5, -1 ],
  [ -1   ,  -2   , -0.5   ],
  [ -0.6 ,  -1   , -0.5   ],
  [ -0.5 ,  -1   , -0.2   ],
  [ -0.3 ,  -0.5 , -0.2   ],
  [ -0.2 ,  -0.5 , -0.1   ],
  [ -0.1 ,  -0.2 , -0.05  ],
  [ -0.06,  -0.1 , -0.05  ],
  [ -0.05,  -0.1 , -0.02  ],
  [ -0.03,  -0.05, -0.02  ],
  [ -0.02,  -0.05, -0.01  ],
  [ -0.01,  -0.02, -0.005 ],

  [ 0, 0, 0 ],
  [ 0.01, 0.005, 0.02 ],
  [ 0.02, 0.01, 0.05 ],
  [ 0.03, 0.02, 0.05 ],
  [ 0.05, 0.02, 0.1 ],
  [ 0.06, 0.05, 0.1 ],
  [ 0.1, 0.05, 0.2 ],
  [ 0.2, 0.1, 0.5 ],
  [ 0.3, 0.2, 0.5 ],
  [ 0.5, 0.2, 1 ],
  [ 0.6, 0.5, 1 ],
  [ 1, 0.5, 2 ],
  [ 2, 1, 5 ],
  [ 3, 2, 5 ],
  [ 5, 2, 10 ],
  [ 6, 5, 10 ],
  [ 10, 5, 20 ],
  [ 11, 10, 20 ],
  [ 100, 50, 200 ],
 );

for my $test ( @round_tests )
{
  my $down = round_pow( down => $test->[0] );
  my $up   = round_pow( up   => $test->[0] );

  ok( $test->[1] == $down && $test->[2] == $up, 
      'round_pow(' . $test->[0] . ')' );
}