A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
one-uniform-random-variable-many-get-value-calls-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 University of Washington
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mitch Watrous (watrous@u.washington.edu)
18
*/
19
20
#include "ns3/config.h"
21
#include "ns3/double.h"
22
#include "ns3/random-variable-stream.h"
23
#include "ns3/test.h"
24
25
#include <vector>
26
27
/**
28
* \file
29
* \ingroup core-tests
30
* \ingroup randomvariable
31
* \ingroup rng-tests
32
* Test for one uniform random variable stream.
33
*/
34
35
namespace
ns3
36
{
37
38
namespace
tests
39
{
40
41
/**
42
* \ingroup rng-tests
43
* Test case for one uniform distribution random variable stream generator
44
*/
45
class
OneUniformRandomVariableManyGetValueCallsTestCase
:
public
TestCase
46
{
47
public
:
48
OneUniformRandomVariableManyGetValueCallsTestCase
();
49
~OneUniformRandomVariableManyGetValueCallsTestCase
()
override
;
50
51
private
:
52
void
DoRun
()
override
;
53
};
54
55
OneUniformRandomVariableManyGetValueCallsTestCase::
56
OneUniformRandomVariableManyGetValueCallsTestCase
()
57
:
TestCase
(
"One Uniform Random Variable with Many GetValue() Calls"
)
58
{
59
}
60
61
OneUniformRandomVariableManyGetValueCallsTestCase::
62
~OneUniformRandomVariableManyGetValueCallsTestCase
()
63
{
64
}
65
66
void
67
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
()
68
{
69
const
double
min = 0.0;
70
const
double
max = 10.0;
71
72
Config::SetDefault
(
"ns3::UniformRandomVariable::Min"
,
DoubleValue
(min));
73
Config::SetDefault
(
"ns3::UniformRandomVariable::Max"
,
DoubleValue
(max));
74
75
Ptr<UniformRandomVariable>
uniform = CreateObject<UniformRandomVariable>();
76
77
// Get many values from 1 random number generator.
78
double
value;
79
const
int
count = 100000000;
80
for
(
int
i = 0; i < count; i++)
81
{
82
value = uniform->GetValue();
83
84
NS_TEST_ASSERT_MSG_GT
(value, min,
"Value less than minimum."
);
85
NS_TEST_ASSERT_MSG_LT
(value, max,
"Value greater than maximum."
);
86
}
87
}
88
89
/**
90
* \ingroup rng-tests
91
* Test suite for one uniform distribution random variable stream generator
92
*/
93
class
OneUniformRandomVariableManyGetValueCallsTestSuite
:
public
TestSuite
94
{
95
public
:
96
OneUniformRandomVariableManyGetValueCallsTestSuite
();
97
};
98
99
OneUniformRandomVariableManyGetValueCallsTestSuite::
100
OneUniformRandomVariableManyGetValueCallsTestSuite
()
101
:
TestSuite
(
"one-uniform-random-variable-many-get-value-calls"
,
Type
::PERFORMANCE)
102
{
103
AddTestCase
(
new
OneUniformRandomVariableManyGetValueCallsTestCase
);
104
}
105
106
/**
107
* \ingroup rng-tests
108
* OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
109
*/
110
static
OneUniformRandomVariableManyGetValueCallsTestSuite
111
g_oneUniformRandomVariableManyGetValueCallsTestSuite
;
112
113
}
// namespace tests
114
115
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TestCase
encapsulates test code
Definition:
test.h:1061
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:302
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1273
ns3::TestSuite::Type
Type
Type of test.
Definition:
test.h:1280
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase
Test case for one uniform distribution random variable stream generator.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:46
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
~OneUniformRandomVariableManyGetValueCallsTestCase() override
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:62
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:67
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
OneUniformRandomVariableManyGetValueCallsTestCase()
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:56
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestSuite
Test suite for one uniform distribution random variable stream generator.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:94
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite()
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:100
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:894
ns3::tests::g_oneUniformRandomVariableManyGetValueCallsTestSuite
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:111
NS_TEST_ASSERT_MSG_LT
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition:
test.h:710
NS_TEST_ASSERT_MSG_GT
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition:
test.h:875
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
test
one-uniform-random-variable-many-get-value-calls-test-suite.cc
Generated on Tue May 28 2024 23:34:48 for ns-3 by
1.9.6