1 package Math::GSL::Chebyshev::Test;
4 use base q{Test::Class};
5 use Math::GSL::Chebyshev qw/:all/;
6 use Math::GSL::Test qw/:all/;
7 use Math::GSL qw/:all/;
8 use Test::More tests => 10;
11 sub make_fixture : Test(setup) {
13 $self->{cheb} = gsl_cheb_alloc(40);
16 sub teardown : Test(teardown) {
18 gsl_cheb_free($self->{cheb});
21 sub GSL_CHEB_ALLOC : Tests {
23 isa_ok($self->{cheb}, 'Math::GSL::Chebyshev');
26 sub GSL_CHEB_INIT : Tests {
28 my $func = sub { my $x = shift; return sin(cos($x)) };
30 ok_status(gsl_cheb_init( $self->{cheb}, $func, 0, 1));
33 sub GSL_CHEB_EVAL : Tests {
35 my $func = sub { my $x = shift; return sin(cos($x)) };
37 gsl_cheb_init( $self->{cheb}, $func, 0, 1);
38 ok_similar( [ sin(cos(0.5)) ], [gsl_cheb_eval($self->{cheb}, 0.5 ) ] );
41 sub GSL_CHEB_EVAL_ERR : Tests {
43 my $func = sub { my $x = shift; return sin(cos($x)) };
45 gsl_cheb_init( $self->{cheb}, $func, 0, 1);
46 my ($status,$result,$err) = gsl_cheb_eval_err($self->{cheb}, 0.5 );
48 ok_similar( [ sin(cos(0.5)) ], [ $result ], 'gsl_cheb_eval_err result');
49 ok( defined $err , 'error is defined');
52 sub GSL_CHEB_CALC_DERIV : Tests {
54 my $deriv = gsl_cheb_alloc(40);
55 my $func = sub { my $x = shift; return sin(cos($x)) };
56 gsl_cheb_init( $self->{cheb}, $func, 0, 1);
57 ok_status(gsl_cheb_calc_deriv($deriv, $self->{cheb} ));
58 isa_ok($deriv, 'Math::GSL::Chebyshev');
61 sub GSL_CHEB_CALC_INTEGRAL : Tests {
63 my $integral = gsl_cheb_alloc(40);
64 my $func = sub { my $x = shift; return sin(cos($x)) };
65 gsl_cheb_init( $self->{cheb}, $func, 0, 1);
66 ok_status(gsl_cheb_calc_integ($integral, $self->{cheb} ));
67 isa_ok($integral, 'Math::GSL::Chebyshev');
69 Test::Class->runtests;