1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as
3# `perl 08_comparefloat.t'
4
5#########################
6
7use Test::More tests => 9;
8BEGIN { use_ok('Image::PBMlib') };
9
10use strict;
11
12use vars qw( $val $set );
13
14$set = "comparefloatval";
15
16$val = comparefloatval( (1/255), (100/25500));
17ok($val == 0, "$set 1/255 == 100/25500");
18
19# these are about .00000089 different
20$val = comparefloatval( (257/4095), (4113/65535));
21ok($val == 0, "$set 257/4095 == 4113/65535");
22
23$val = comparefloatval( "0,", (1/65535));
24ok($val == -1, "$set 0, < 1/65535");
25
26$val = comparefloatval( "1,", (65534/65535));
27ok($val == 1, "$set 1, > 65534/65535");
28
29$set = "comparefloattriple";
30
31$val = comparefloattriple("0.0,1,0,", [ 0, 1.0, 0.0 ]);
32ok($val == 0, "$set 0.0,1,0, == [ 0, 1.0, 0.0 ] ");
33
34$val = comparefloattriple([ 0.5, 0.1, 0.9 ], ".500001,0.099999,0.90000");
35ok($val == 0, "$set [ 0.5, 0.1, 0.9 ] == .500001,0.099999,0.90000");
36
37$val = comparefloattriple([ 0.5, 0.2, 0.9 ], [ 0.5, 0.20001, 0.9 ]);
38ok($val == -1, "$set [ 0.5, 0.2, 0.9 ] < [ 0.5, 0.20001, 0.9 ]");
39
40$val = comparefloattriple([ 0.5, 0.2, 0.8 ], [ 0.5, 0.2, 0.79 ]);
41ok($val == 1, "$set [ 0.5, 0.2, 0.8 ] > [ 0.5, 0.2, 0.79 ]");
42
43