A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
many-uniform-random-variables-one-get-value-call-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
35
namespace
ns3
36
{
37
38
namespace
tests
39
{
40
45
class
ManyUniformRandomVariablesOneGetValueCallTestCase
:
public
TestCase
46
{
47
public
:
49
ManyUniformRandomVariablesOneGetValueCallTestCase
();
51
~ManyUniformRandomVariablesOneGetValueCallTestCase
()
override
;
52
53
private
:
54
void
DoRun
()
override
;
55
};
56
57
ManyUniformRandomVariablesOneGetValueCallTestCase::
58
ManyUniformRandomVariablesOneGetValueCallTestCase
()
59
:
TestCase
(
"Many Uniform Random Variables with One GetValue() Call"
)
60
{
61
}
62
63
ManyUniformRandomVariablesOneGetValueCallTestCase::
64
~ManyUniformRandomVariablesOneGetValueCallTestCase
()
65
{
66
}
67
68
void
69
ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun
()
70
{
71
const
double
min
= 0.0;
72
const
double
max
= 10.0;
73
74
Config::SetDefault
(
"ns3::UniformRandomVariable::Min"
,
DoubleValue
(
min
));
75
Config::SetDefault
(
"ns3::UniformRandomVariable::Max"
,
DoubleValue
(
max
));
76
77
// Get 1 value from many uniform random number generators.
78
double
value;
79
const
int
count = 1000000;
80
std::vector<Ptr<UniformRandomVariable>> uniformStreamVector(count);
81
for
(
int
i = 0; i < count; i++)
82
{
83
uniformStreamVector.push_back(CreateObject<UniformRandomVariable>());
84
value = uniformStreamVector.back()->GetValue();
85
86
NS_TEST_ASSERT_MSG_GT
(value,
min
,
"Value less than minimum."
);
87
NS_TEST_ASSERT_MSG_LT
(value,
max
,
"Value greater than maximum."
);
88
}
89
}
90
95
class
ManyUniformRandomVariablesOneGetValueCallTestSuite
:
public
TestSuite
96
{
97
public
:
99
ManyUniformRandomVariablesOneGetValueCallTestSuite
();
100
};
101
102
ManyUniformRandomVariablesOneGetValueCallTestSuite::
103
ManyUniformRandomVariablesOneGetValueCallTestSuite
()
104
:
TestSuite
(
"many-uniform-random-variables-one-get-value-call"
, PERFORMANCE)
105
{
106
AddTestCase
(
new
ManyUniformRandomVariablesOneGetValueCallTestCase
);
107
}
108
113
static
ManyUniformRandomVariablesOneGetValueCallTestSuite
114
g_manyUniformRandomVariablesOneGetValueCallTestSuite
;
115
116
}
// namespace tests
117
118
}
// namespace ns3
min
#define min(a, b)
Definition:
80211b.c:41
max
#define max(a, b)
Definition:
80211b.c:42
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase
Test case for many uniform distribution random variable stream generators.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:46
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase
ManyUniformRandomVariablesOneGetValueCallTestCase()
Constructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:58
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:69
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase
~ManyUniformRandomVariablesOneGetValueCallTestCase() override
Destructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:64
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestSuite
Test suite for many uniform distribution random variable stream generators.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:96
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOneGetValueCallTestSuite
ManyUniformRandomVariablesOneGetValueCallTestSuite()
Constructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:103
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:890
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:709
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:874
ns3::tests::g_manyUniformRandomVariablesOneGetValueCallTestSuite
static ManyUniformRandomVariablesOneGetValueCallTestSuite g_manyUniformRandomVariablesOneGetValueCallTestSuite
ManuUniformRandomVariablesOneGetValueCallTestSuite instance variable.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:114
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
core
test
many-uniform-random-variables-one-get-value-call-test-suite.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1