A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
core
test
many-uniform-random-variables-one-get-value-call-test-suite.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mitch Watrous (watrous@u.washington.edu)
19
*/
20
21
#include "ns3/test.h"
22
#include "ns3/config.h"
23
#include "ns3/double.h"
24
#include "ns3/random-variable-stream.h"
25
#include <vector>
26
27
36
namespace
ns3
{
37
38
namespace
tests {
39
40
45
class
ManyUniformRandomVariablesOneGetValueCallTestCase
:
public
TestCase
46
{
47
public
:
49
ManyUniformRandomVariablesOneGetValueCallTestCase
();
51
virtual
~ManyUniformRandomVariablesOneGetValueCallTestCase
();
52
53
private
:
54
virtual
void
DoRun
(
void
);
55
};
56
57
ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase
()
58
:
TestCase
(
"Many Uniform Random Variables with One GetValue() Call"
)
59
{
60
}
61
62
ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase
()
63
{
64
}
65
66
void
67
ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun
(
void
)
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
// Get 1 value from many uniform random number generators.
76
double
value;
77
const
int
count = 1000000;
78
std::vector< Ptr<UniformRandomVariable> > uniformStreamVector (count);
79
for
(
int
i = 0; i < count; i++)
80
{
81
uniformStreamVector.push_back (CreateObject<UniformRandomVariable> ());
82
value = uniformStreamVector.back ()->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
93
class
ManyUniformRandomVariablesOneGetValueCallTestSuite
:
public
TestSuite
94
{
95
public
:
97
ManyUniformRandomVariablesOneGetValueCallTestSuite
();
98
};
99
100
ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOneGetValueCallTestSuite
()
101
:
TestSuite
(
"many-uniform-random-variables-one-get-value-call"
, PERFORMANCE)
102
{
103
AddTestCase
(
new
ManyUniformRandomVariablesOneGetValueCallTestCase
);
104
}
105
110
static
ManyUniformRandomVariablesOneGetValueCallTestSuite
g_manyUniformRandomVariablesOneGetValueCallTestSuite
;
111
112
113
}
// namespace tests
114
115
}
// namespace ns3
ns3::tests::g_manyUniformRandomVariablesOneGetValueCallTestSuite
static ManyUniformRandomVariablesOneGetValueCallTestSuite g_manyUniformRandomVariablesOneGetValueCallTestSuite
ManuUniformRandomVariablesOneGetValueCallTestSuite instance variable.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:110
min
#define min(a, b)
Definition:
80211b.c:42
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1342
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase
virtual ~ManyUniformRandomVariablesOneGetValueCallTestCase()
Destructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:62
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:93
ns3::TestCase
encapsulates test code
Definition:
test.h:1155
max
#define max(a, b)
Definition:
80211b.c:43
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase
ManyUniformRandomVariablesOneGetValueCallTestCase()
Constructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:57
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:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOneGetValueCallTestSuite
ManyUniformRandomVariablesOneGetValueCallTestSuite()
Constructor.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:100
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:782
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:997
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition:
double.h:41
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:811
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
many-uniform-random-variables-one-get-value-call-test-suite.cc:67
Generated on Wed Nov 7 2018 10:01:51 for ns-3 by
1.8.14