Adding some tests for gsl_complex_vector function and one fail, in link with the...
[Math-GSL.git] / lib / Math / GSL / NTuple / Test.pm
blobe3a63f0c2a2430f57539cf336abf8bb94c6673b1
1 package Math::GSL::NTuple::Test;
2 use base q{Test::Class};
3 use Test::More;
4 use Test::Exception;
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/;
9 use Data::Dumper;
10 use strict;
12 BEGIN{ gsl_set_error_handler_off(); }
14 sub make_fixture : Test(setup) {
15 my $self = shift;
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 {
31 my $self = shift;
32 isa_ok ($self->{ntuple}, 'Math::GSL::NTuple::gsl_ntuple');
33 ok( -e 'ntuple', 'ntuple file created');
36 sub GSL_NTUPLE_OPEN_CLOSE : Tests {
37 my $self = shift;
38 my $stuff = [];
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 {
45 my $self = shift;
46 my $data = [1..100];
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 {
53 my $self = shift;
54 my $data = [1..100];
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);