// system include files used for I/O
# include <iostream>
// define the types integer and doublereal
# include <f2cad/f2cad.hpp>
// ../add2lib.sh uses this comment for extern command 
extern test_result dbesks(void);
extern test_result dbskes(void);
extern test_result d9knus(void);
extern test_result d9lgmc(void);
extern test_result dgamma(void);
extern test_result dint(void);
extern test_result dcsevl(void);
extern test_result dgamlm(void);
extern test_result initds(void);
extern test_result idamax(void);
extern test_result daxpy(void);
extern test_result ddot(void);
extern test_result dgefa(void);
extern test_result dgesl(void);
extern test_result dscal(void);
// xerror is a special case
extern void xerror(void);
// function that runs one test
bool run(test_result test_fun(void), const char *name)
{
	bool ok = true;
	switch( test_fun() )
	{
		case test_none:
		std::cout << "None: " << name << std::endl;
		break;
		case test_pass:
		std::cout << "Pass: " << name << std::endl;
		break;
		case test_fail:
		std::cout << "Fail: " << name << std::endl;
		ok = false;
		break;
	}
	return ok;
}
// main program that runs all the examples
int main(void)
{	bool ok = true;
	using std::cout;
	using std::endl;
	// ../add2lib.sh uses this comment for run command 
	ok &= run( dbesks , "dbesks" );
	ok &= run( dbskes , "dbskes" );
	ok &= run( d9knus , "d9knus" );
	ok &= run( d9lgmc , "d9lgmc" );
	ok &= run( dgamma , "dgamma" );
	ok &= run( dint , "dint" );
	ok &= run( dcsevl , "dcsevl" );
	ok &= run( dgamlm , "dgamlm" );
	ok &= run( initds , "initds" );
	ok &= run( idamax , "idamax" );
	ok &= run( daxpy  , "daxpy"  );
	ok &= run( ddot   , "ddot"   );
	ok &= run( dgefa  , "dgefa"  );
	ok &= run( dgesl  , "dgesl"  );
	ok &= run( daxpy  , "dscal"  );
	if( ok )
		cout << endl << "Pass: None of the tests above failed." << endl;
	else	cout << endl << "Fail: At least one test above failed." << endl;
	cout << "      The next two lines should be identical:" << endl;
	// xerror is a special case because it is not checked automatically
	// and must be checked by eye.
	cout << "Pass: xerror" << endl;
	xerror();
	cout << endl;
	if( ok )
		return 0;
	return 1;
}