1 | // $Id: rnd_test.cc 1610 2008-11-04 19:15:54Z peter $ |
---|

2 | |
---|

3 | /* |
---|

4 | Copyright (C) 2003 Daniel Dalevi |
---|

5 | Copyright (C) 2004 Jari Häkkinen |
---|

6 | Copyright (C) 2005 Jari Häkkinen, Peter Johansson |
---|

7 | Copyright (C) 2006 Jari Häkkinen |
---|

8 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|

9 | Copyright (C) 2008 Peter Johansson |
---|

10 | |
---|

11 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|

12 | |
---|

13 | The yat library is free software; you can redistribute it and/or |
---|

14 | modify it under the terms of the GNU General Public License as |
---|

15 | published by the Free Software Foundation; either version 3 of the |
---|

16 | License, or (at your option) any later version. |
---|

17 | |
---|

18 | The yat library is distributed in the hope that it will be useful, |
---|

19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|

20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|

21 | General Public License for more details. |
---|

22 | |
---|

23 | You should have received a copy of the GNU General Public License |
---|

24 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|

25 | */ |
---|

26 | |
---|

27 | #include "Suite.h" |
---|

28 | |
---|

29 | #include "yat/random/random.h" |
---|

30 | #include "yat/statistics/Histogram.h" |
---|

31 | |
---|

32 | #include <iostream> |
---|

33 | #include <sstream> |
---|

34 | #include <fstream> |
---|

35 | |
---|

36 | int main(int argc, char* argv[]) |
---|

37 | { |
---|

38 | using namespace theplu::yat::random; |
---|

39 | theplu::yat::test::Suite suite(argc, argv); |
---|

40 | suite.err() << "testing rnd" << std::endl; |
---|

41 | |
---|

42 | RNG* rng=RNG::instance(); |
---|

43 | rng->seed_from_devurandom(); |
---|

44 | |
---|

45 | // testing that minimal integer is zero for the generator |
---|

46 | suite.err() << "Checking that RNG minimum value is zero" << std::endl; |
---|

47 | if (rng->min()){ |
---|

48 | suite.err() << "Error: rng->min is not zero" << std::endl; |
---|

49 | suite.add(false); |
---|

50 | } |
---|

51 | |
---|

52 | suite.err() << "Checking that all random generators can be constructed\n"; |
---|

53 | theplu::yat::statistics::Histogram histogram(0,100,1000); |
---|

54 | DiscreteGeneral dg(histogram); |
---|

55 | DiscreteUniform du; |
---|

56 | Poisson p; |
---|

57 | ContinuousUniform cu; |
---|

58 | ContinuousGeneral cg(histogram); |
---|

59 | Exponential e; |
---|

60 | Gaussian g; |
---|

61 | |
---|

62 | return suite.return_value(); |
---|

63 | } |
---|