// RandomGenerator_t.cpp #include "RandomGeneratorTest.h" #include #include #include #include using std::string; using std::vector; using std::cout; using std::cerr; using std::endl; //********************************************************************** int main( ) { string component = "RandomGenerator"; string ok_prefix = component + " (I): "; string error_prefix = component + " test (E): "; cout << ok_prefix << "---------- Testing component " + component + ". ----------" << endl; // Make sure assert is enabled. bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //******************************************************************** // Verify that each generated value is different and is in range. cout << ok_prefix << "Test default sequence." << endl; double min = 2.0; double max = 5.0; long seed = 246813579L; RandomGeneratorTest rgen(min,max); cout << rgen << endl; int ntest = 20; int itest; vector values; vector::const_iterator ival; for ( itest=0; itest= min ); assert( newval <= max ); } values.push_back(newval); } //******************************************************************** // Verify that two generators starting with the same seed give the // same values. cout << ok_prefix << "Test sequence with seed." << endl; rgen.set_seed(seed); RandomGeneratorTest rgen2(min,max,seed); for ( itest=0; itest