Move tests out of lib/Math/GSL/*/Test.pm into t/*.t directly
[Math-GSL.git] / t / Combination.t
blob39ec41640f5953595ab3293e4d91914657bb7e9d
1 package Math::GSL::Combination::Test;
2 use Math::GSL::Test qw/:all/;
3 use base q{Test::Class};
4 use Test::More;
5 use Math::GSL::Combination qw/:all/;
6 use Math::GSL::Errno qw/:all/;
7 use Math::GSL qw/:all/;
8 use strict;
10 sub make_fixture : Test(setup) {
11   my $self = shift;
12   $self->{comb} = gsl_combination_calloc(5,5);
13   $self->{oo} = Math::GSL::Combination->new(5,5);
16 sub teardown : Test(teardown) {
19 sub GSL_COMBINATION_ALLOC : Tests { 
20     my $c = gsl_combination_alloc(2,2);
21     isa_ok($c, 'Math::GSL::Combination');
24 sub GSL_COMBINATION_CALLOC : Tests { 
25     my $c = gsl_combination_calloc(2,2);
26     isa_ok($c, 'Math::GSL::Combination');
29 sub GSL_COMBINATION_GET : Tests {
30     my $self = shift; 
31     map {ok(gsl_combination_get($self->{comb}, $_) eq $_) } (0..4);   
34 sub GSL_COMBINATION_NEXT : Tests {
35     my $c = gsl_combination_calloc(4,2);  
36     is_deeply( [ map{ gsl_combination_get($c,$_) } (0..1) ] , [ 0 .. 1 ] );
37     my $status = gsl_combination_next($c);
38     ok_status($status, $GSL_SUCCESS);    
39     local $TODO = "Seems to have a problem with the gsl_combination_next function, see the gsl doc example for reference";
40     is_deeply( [ map{ gsl_combination_get($c,$_) } (0..1) ] , [ 0 .. 2 ] );
41
43 sub NEW : Tests { 
44     my $c = Math::GSL::Combination->new(5,5);
45     isa_ok($c, 'Math::GSL::Combination');
46     map {ok(gsl_combination_get($c->raw, $_) eq $_) } (0..4);   
49 sub AS_LIST: Tests { 
50     my $self = shift;
51     is_deeply( [ $self->{oo}->as_list ] , [ 0 .. 4 ] );
54 sub LENGTH : Tests {
55     my $self = shift;
56     ok($self->{oo}->length eq 5);
59 sub ELEMENTS : Tests {
60     my $self = shift;
61     ok($self->{oo}->elements eq 5);
64 sub NEXT : Tests {
65     my $self = shift;
66     my $status = $self->{oo}->next;
67     ok_status($status, $GSL_FAILURE);   
68     is_deeply( [ $self->{oo}->as_list ] , [ 0 .. 4 ] );
69     my $c = Math::GSL::Combination->new(4,2);
70     is_deeply( [ $c->as_list ] , [ 0 .. 1 ] );
71     $status = $c->next;
72     ok_status($status, $GSL_SUCCESS);   
73     local $TODO = "Seems to have a problem with the gsl_combination_next function, see the gsl doc example for reference";
74     is_deeply( [ $c->as_list ] , [ 0 .. 2 ] );
76 Test::Class->runtests;