1 package Math
::GSL
::NTuple
::Test
;
2 use base
q{Test::Class};
5 use Math
::GSL
::NTuple qw
/:all/;
6 use Math
::GSL
::Const qw
/:all/;
7 use Math
::GSL
::Errno qw
/:all/;
8 use Math
::GSL qw
/:all/;
12 BEGIN{ gsl_set_error_handler_off
(); }
14 sub make_fixture
: Test
(setup
) {
16 my $size = int rand(100);
17 $self->{size
} = $size;
18 my $stuff = [1..$size];
20 $self->{ntuple
} = gsl_ntuple_create
('ntuple', $stuff ,$size);
21 gsl_ntuple_write
($self->{ntuple
});
22 gsl_ntuple_close
($self->{ntuple
});
25 sub teardown
: Test
(teardown
) {
26 unlink 'ntuple' if -f
'ntuple';
27 unlink 'ntuple2' if -f
'ntuple2';
30 sub GSL_NTUPLE_CREATE
: Tests
{
32 isa_ok
($self->{ntuple
}, 'Math::GSL::NTuple::gsl_ntuple');
33 ok
( -e
'ntuple', 'ntuple file created');
36 sub GSL_NTUPLE_OPEN_CLOSE
: Tests
{
39 my $ntuple = gsl_ntuple_open
('ntuple',$stuff, $self->{size
} );
40 isa_ok
($ntuple,'Math::GSL::NTuple');
41 ok_status
(gsl_ntuple_close
($ntuple));
44 sub GSL_NTUPLE_WRITE
: Tests
{
47 my $base = gsl_ntuple_create
('ntuple', $data, 100);
48 ok_status
(gsl_ntuple_write
($base));
49 ok_status
(gsl_ntuple_close
($base));
52 sub GSL_NTUPLE_READ
: Tests
{
55 my $ntuple = gsl_ntuple_open
('ntuple', $data, 100 );
56 # why does this return an EOF?
57 # perhaps gsl_ntuple_write is not doing it's job, so the file is empty...
58 ok_status
(gsl_ntuple_read
($ntuple),$GSL_EOF);