source: trunk/test/random_distribution.cc @ 3898

Last change on this file since 3898 was 3898, checked in by Peter, 3 years ago

closes #858 and #869

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: random_distribution.cc 3898 2020-03-31 02:02:42Z peter $
2
3/*
4  Copyright (C) 2020 Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <config.h>
23
24#include "Suite.h"
25
26#include "yat/random/ContinuousDistribution.h"
27#include "yat/random/DiscreteDistribution.h"
28
29using namespace theplu::yat;
30
31
32
33void discrete_function(random::Discrete& distribution)
34{
35}
36
37
38void continuous_function(random::Continuous& distribution)
39{
40}
41
42
43template<class RND, typename ResType>
44void test_base(RND& rnd, ResType res)
45{
46  res = rnd();
47  typename RND::param_type p = rnd.param();
48  res = rnd(p);
49  rnd.param(p);
50  test::avoid_compiler_warning(res);
51
52}
53
54
55template<class RND>
56void test_discrete(void)
57{
58  RND rnd;
59  discrete_function(rnd);
60  unsigned long int result = 0;
61  test_base(rnd, result);
62}
63
64
65template<class RND>
66void test_continuous(void)
67{
68  RND rnd;
69  continuous_function(rnd);
70  double result = 0.0;
71  test_base(rnd, result);
72}
73
74
75int main(int argc, char* argv[])
76{
77  test::Suite suite(argc, argv);
78
79  test_discrete<random::Bernoulli>();
80  test_discrete<random::Beta>();
81  test_discrete<random::NegativeBinomial>();
82  test_discrete<random::Hyperexponential>();
83  test_discrete<random::Weibull>();
84  test_discrete<random::Laplace>();
85
86  test_continuous<random::Cauchy>();
87  test_continuous<random::ChiSquared>();
88  test_continuous<random::ExtremeValue>();
89  test_continuous<random::FisherF>();
90  test_continuous<random::Gamma>();
91  test_continuous<random::Lognormal>();
92  test_continuous<random::NonCentralChiSquared>();
93  test_continuous<random::StudentT>();
94
95  return suite.return_value();
96}
Note: See TracBrowser for help on using the repository browser.