Changeset 798 for trunk/test/rnd_test.cc


Ignore:
Timestamp:
Mar 13, 2007, 12:52:43 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Removed unnecessary #include. Added tests for random number distributions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/rnd_test.cc

    r680 r798  
    2323
    2424#include "yat/random/random.h"
     25#include "yat/statistics/Histogram.h"
    2526
    2627#include <iostream>
     
    3031int main(const int argc,const char* argv[])
    3132{
    32   std::ostream* error;
     33  using namespace theplu::yat::random;
     34  std::ostream* message;
    3335  if (argc>1 && argv[1]==std::string("-v"))
    34     error = &std::cerr;
     36    message = &std::cerr;
    3537  else {
    36     error = new std::ofstream("/dev/null");
     38    message = new std::ofstream("/dev/null");
    3739    if (argc>1)
    3840      std::cout << "rnd_test -v : for printing extra information\n";
    3941  }
    40   *error << "testing rnd" << std::endl;
     42  *message << "testing rnd" << std::endl;
    4143  bool ok = true;
    4244
    43   theplu::yat::random::RNG* rng=theplu::yat::random::RNG::instance();
     45  RNG* rng=RNG::instance();
     46  rng->seed_from_devurandom();
     47
    4448  // testing that minimal integer is zero for the generator
     49  *message << "Checking that RNG minimum value is zero" << std::endl;
    4550  if (rng->min()){
    46     *error << "Error: rng->min is not zero" << std::endl;
     51    *message << "Error: rng->min is not zero" << std::endl;
    4752    ok = false;
    4853  }
    4954
    50   if (error!=&std::cerr)
    51     delete error;
     55  *message << "Checking that all random generator can be constructed"
     56           << std::endl;
     57  theplu::yat::statistics::Histogram histogram(0,100,1000);
     58  DiscreteGeneral dg(histogram);
     59  DiscreteUniform du;
     60  Poisson p;
     61  ContinuousUniform cu;
     62  ContinuousGeneral cg(histogram);
     63  Exponential e;
     64  Gaussian g;
     65
     66  if (message!=&std::cerr)
     67    delete message;
    5268
    5369  return (ok ? 0 : -1);
Note: See TracChangeset for help on using the changeset viewer.