1 package Math::GSL::NTuple::Test;
2 use base q{Test::Class};
3 use Test::More tests => 11;
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::Test qw/:all/;
12 BEGIN{ gsl_set_error_handler_off(); }
14 END { warn "This is the end" }
16 sub make_fixture : Test(setup) {
18 my $size = 2 + int rand(10);
19 $self->{size} = $size;
20 my $stuff = [1..$size];
22 my ($ntuple) = gsl_ntuple_create('ntuple', $stuff ,$size);
23 $self->{ntuple} = $ntuple;
24 gsl_ntuple_write($self->{ntuple});
25 gsl_ntuple_close($self->{ntuple});
28 sub teardown : Test(teardown) {
29 unlink 'ntuple' if -f 'ntuple';
32 sub GSL_NTUPLE_CREATE : Tests(2) {
34 isa_ok ($self->{ntuple}, 'Math::GSL::NTuple::gsl_ntuple');
35 ok( -e 'ntuple', 'ntuple file created');
38 sub GSL_NTUPLE_OPEN_CLOSE : Tests(2) {
41 my $ntuple = gsl_ntuple_open('ntuple',$stuff, $self->{size} );
42 isa_ok($ntuple,'Math::GSL::NTuple');
43 ok_status(gsl_ntuple_close($ntuple));
46 sub GSL_NTUPLE_WRITE: Tests(2) {
49 my $base = gsl_ntuple_create('ntuple', $data, 255);
50 ok_status(gsl_ntuple_write($base));
51 ok_status(gsl_ntuple_close($base));
54 sub GSL_NTUPLE_READ: Tests(2) {
56 my $data = [ (42) x $self->{size} ];
57 my $ntuple = Math::GSL::NTuple::gsl_ntuple->new;
58 $ntuple = gsl_ntuple_open('ntuple', $data, $self->{size} );
60 ok_status(gsl_ntuple_read($ntuple));
62 my $cdata = $ntuple->swig_ntuple_data_get ;
63 # warn Dumper [ $data, $cdata ];
64 ok_status(gsl_ntuple_close($ntuple));
67 sub GSL_NTUPLE_GSL_NTUPLE: Tests(1) {
68 my $ntuple = Math::GSL::NTuple::gsl_ntuple->new;
69 isa_ok($ntuple,'Math::GSL::NTuple::gsl_ntuple');
72 sub GSL_NTUPLE_OBJECT: Tests(2) {
73 my $ntuple = Math::GSL::NTuple->new;
74 isa_ok($ntuple,'Math::GSL::NTuple');
75 isa_ok($ntuple->raw,'Math::GSL::NTuple::gsl_ntuple');
79 Test::Class->runtests;