Skip to content

Commit

Permalink
fix space tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lichtkind committed Apr 11, 2024
1 parent b163273 commit 1832930
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions t/04_space.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use v5.12;
use warnings;
use Test::More tests => 52;
use Test::More tests => 67;
use Test::Warn;

BEGIN { unshift @INC, 'lib', '../lib'}
Expand Down Expand Up @@ -85,30 +85,27 @@ is( $val[2], 3, 'third value correctly deconverted');
is( $val[3], 4, 'fourth value correctly deconverted');



my @d = $space->delta([2,3,4,5], [1,5,1,1] );
is( int @d, 4, 'delta result has right length');
exit 0;
is( $d[0], -1, 'first value correctly deconverted');
is( $d[1], 2, 'second value correctly deconverted');
is( $d[2], -3, 'third value correctly deconverted');
is( $d[3], -4, 'fourth value correctly deconverted');


my @tr = $space->clamp([-1, 0, 20.1, 21, 1]);
is( int @tr, 4, 'clamp kept correct vector length = 4');
is( $tr[0], 0, 'clamp up value below minimum');
is( $tr[1], 0, 'do not touch minimal value');
is( $tr[2], 20, 'clamp real into int');
is( $tr[3], 20, 'clamp down value above range max');

is( $space->check([1,2,3,4]), undef, 'all values in range');

my @norm = $space->normalize([0, 10, 20, 15]);
is( int @norm, 4, 'normalized 4 into 4 values');
is( $norm[0], 0, 'normalized first min value');
is( $norm[1], 0.5, 'normalized second mid value');
is( $norm[2], 1, 'normalized third max value');
is( $norm[3], 0.75, 'normalized fourth value');
my $d = $space->delta([2,3,4,5], [1,5,1,1] );
is( int @$d, 4, 'delta result has right length');
is( $d->[0], -1, 'first value correctly deconverted');
is( $d->[1], 2, 'second value correctly deconverted');
is( $d->[2], -3, 'third value correctly deconverted');
is( $d->[3], -4, 'fourth value correctly deconverted');

my $tr = $space->clamp([-1, 0, 20.1, 21, 1]);
is( int @$tr, 4, 'clamp kept correct vector length = 4');
is( $tr->[0], 0, 'clamp up value below minimum');
is( $tr->[1], 0, 'do not touch minimal value');
is( $tr->[2], 20, 'clamp real into int');
is( $tr->[3], 20, 'clamp down value above range max');

is( ref $space->in_range([1,2,3,4]), 'ARRAY', 'all values in range');

my $norm = $space->normalize([0, 10, 20, 15]);
is( int @$norm, 4, 'normalized 4 into 4 values');
is( $norm->[0], 0, 'normalized first min value');
is( $norm->[1], 0.5, 'normalized second mid value');
is( $norm->[2], 1, 'normalized third max value');
is( $norm->[3], 0.75, 'normalized fourth value');

exit 0;

0 comments on commit 1832930

Please sign in to comment.