1 package Math::GSL::DHT::Test;
2 use Math::GSL::Test qw/:all/;
3 use base q{Test::Class};
5 use Math::GSL::DHT qw/:all/;
6 use Math::GSL qw/:all/;
8 use Math::GSL::Errno qw/:all/;
11 BEGIN { gsl_set_error_handler_off(); }
13 sub make_fixture : Test(setup) {
16 sub teardown : Test(teardown) {
19 sub GSL_DHT_ALLOC_FREE : Tests {
20 my $dht = gsl_dht_alloc(5);
21 isa_ok($dht, 'Math::GSL::DHT');
23 ok(!$@, 'gsl_dht_free');
27 my $dht = gsl_dht_new(128, 1.0, 20);
28 isa_ok($dht, 'Math::GSL::DHT' );
31 sub DHT_SAMPLE_APPLY : Tests {
32 my $f_in = [(0) x 128 ];
33 my $f_out = [(0) x 128 ];
34 my $dht = gsl_dht_new(128, 1.0, 20);
37 my $x = gsl_dht_x_sample($dht, $n);
38 $f_in->[$n] = exp(-$x);
40 ok( $#$f_in = 127, 'gsl_dht_x_sample' );
42 ok_status( gsl_dht_apply($dht, $f_in, $f_out));
43 ok( $#$f_out = 127, 'gsl_dht_apply' );
45 local $TODO = 'need a typemap for $f_in and $f_out';
46 # check that the relative error at most 2%
48 is_similar_relative ($f_out->[0], 0.181, 0.02),
49 "gsl_dht_apply output @{[$f_out->[0]]} != 0.181"
53 Test::Class->runtests;