1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as 3# `perl 02_dectripletofloat.t' 4 5######################### 6 7use Test::More tests => 25; 8BEGIN { use_ok('Image::PBMlib') }; 9 10# Note on value tests: 11# 1/65535 is ~ 0.0000152590 12# we look for a value that is right to 5 places even for max < 65535 13 14use strict; 15 16use vars qw( $rc @valset $rgb $set ); 17 18# does 8 tests 19sub checkset { 20 ok(($valset[0] > 0.99999), "$set: 300/255 as float > 0.99999"); 21 ok(($valset[0] < 1.00001), "$set: 300/255 as float < 1.00001"); 22 23 ok(($valset[1] > 0.00784), "$set: 2/255 as float > 0.00784"); 24 ok(($valset[1] < 0.00785), "$set: 2/255 as float < 0.00785"); 25 26 ok(($valset[2] > 0.78431), "$set: 200/255 as float > 0.78431"); 27 ok(($valset[2] < 0.78432), "$set: 200/255 as float < 0.78432"); 28} 29 30$set = "string to array"; 31@valset = dectripletofloat("300:2:200:", 255); 32# 1.0, 0.00784314, 0.78431373, 33chop(@valset); 34checkset(); 35 36$set = "array to array"; 37@valset = dectripletofloat([ 300, "2:", 200 ], 255); 38# 1.0, 0.00784314, 0.78431373, 39chop(@valset); 40checkset(); 41 42$set = "string to string"; 43$rgb = dectripletofloat("300:2:200", 255); 44# 0.95834223,0.00003052,1.0 45@valset = split(/,/, $rgb); 46checkset(); 47 48$set = "array to string"; 49$rgb = dectripletofloat([ 300, "2:", 200 ], 255); 50# 0.95834223,0.00003052,1.0 51@valset = split(/,/, $rgb); 52checkset(); 53 54 55