# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)

BEGIN { $| = 1; print "1..1\n"; }
END {print "not ok 1\n" unless $loaded;}
use expint;
$loaded = 1;
print "ok 1\n";

######################### End of black magic.

# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):



my $Pi = 3.1415926535;
my $ans0 = sqrt($Pi);
my $tmp0 = expint::localint(-10, -100, 0, 0, 10, -100);
print "$tmp0\n";

if(abs($tmp0-$ans0) > 1e-6)	{
	die "Bad ans 0=$tmp0, should be $ans0";
	}


my $ans1 = sqrt($Pi)/sqrt(2);
my $tmp1 = expint::localint(-10, -200, 0, 0, 10, -200);
print "$tmp1\n";

if(abs($tmp1-$ans1) > 1e-6)	{
	die "Bad ans 1=$tmp1, should be $ans1";
	}


my $ans2 = 0.683;
my $tmp2 = expint::localint(-2, -2, 0, 0, 2, -2)
		/ expint::localint(-10, -50, 0, 0, 10, -50);
print "$tmp2\n";

if(abs($tmp2-$ans2) > 1e-2)	{
	die "Bad ans 2";
	}

my $ans25 = -$ans2/2;
my $tmp25 = expint::endint(0, -2, -2, 0, 0, 2, -2)
		/ expint::localint(-10, -50, 0, 0, 10, -50);
print "$tmp25\n";

if(abs($tmp25-$ans25) > 1e-2)	{
	die "Bad ans 25";
	}


my $ans3 = exp(0.5)-exp(-0.5);
my $tmp3 = expint::localint(-1, -1, 0, 0, 1, 1);
print "$tmp3\n";

if(abs($tmp3-$ans3) > 1e-6)	{
	die "Bad ans 3";
	}


my $ans4 = 1;
my $tmp4 = expint::localint(-2, -2, 0, 0, 2, -2)
		/ expint::localint(-1, -2, 1, 0, 3, -2);
print "$tmp4\n";

if(abs($tmp4-$ans4) > 1e-7)	{
	die "Bad ans 4";
	}


my $ans5 = 2*exp(-1);
my $tmp5 = expint::localint(-2, -1, 0, -1, 2, -1);
print "$tmp5\n";

if(abs($tmp5-$ans5) > 1e-7)	{
	die "Bad ans 4";
	}


print "ok\n";
