A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
one-uniform-random-variable-many-get-value-calls-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
35
namespace
ns3
{
36
37
namespace
tests
{
38
39
44
class
OneUniformRandomVariableManyGetValueCallsTestCase
:
public
TestCase
45
{
46
public
:
48
OneUniformRandomVariableManyGetValueCallsTestCase
();
50
virtual
~OneUniformRandomVariableManyGetValueCallsTestCase
();
51
52
private
:
53
virtual
void
DoRun
(
void
);
54
};
55
56
OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
()
57
:
TestCase
(
"One Uniform Random Variable with Many GetValue() Calls"
)
58
{}
59
60
OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
()
61
{}
62
63
void
64
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
(
void
)
65
{
66
const
double
min
= 0.0;
67
const
double
max
= 10.0;
68
69
Config::SetDefault
(
"ns3::UniformRandomVariable::Min"
,
DoubleValue
(
min
));
70
Config::SetDefault
(
"ns3::UniformRandomVariable::Max"
,
DoubleValue
(
max
));
71
72
Ptr<UniformRandomVariable>
uniform = CreateObject<UniformRandomVariable> ();
73
74
// Get many values from 1 random number generator.
75
double
value;
76
const
int
count = 100000000;
77
for
(
int
i = 0; i < count; i++)
78
{
79
value = uniform->
GetValue
();
80
81
NS_TEST_ASSERT_MSG_GT
(value,
min
,
"Value less than minimum."
);
82
NS_TEST_ASSERT_MSG_LT
(value,
max
,
"Value greater than maximum."
);
83
}
84
}
85
90
class
OneUniformRandomVariableManyGetValueCallsTestSuite
:
public
TestSuite
91
{
92
public
:
94
OneUniformRandomVariableManyGetValueCallsTestSuite
();
95
};
96
97
OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
()
98
:
TestSuite
(
"one-uniform-random-variable-many-get-value-calls"
, PERFORMANCE)
99
{
100
AddTestCase
(
new
OneUniformRandomVariableManyGetValueCallsTestCase
);
101
}
102
107
static
OneUniformRandomVariableManyGetValueCallsTestSuite
g_oneUniformRandomVariableManyGetValueCallsTestSuite
;
108
109
110
}
// namespace tests
111
112
}
// namespace ns3
min
#define min(a, b)
Definition:
80211b.c:42
max
#define max(a, b)
Definition:
80211b.c:43
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ns3::Ptr< UniformRandomVariable >
ns3::TestCase
encapsulates test code
Definition:
test.h:994
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1188
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Definition:
random-variable-stream.cc:181
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:45
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:64
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
virtual ~OneUniformRandomVariableManyGetValueCallsTestCase()
Destructor.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:60
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
OneUniformRandomVariableManyGetValueCallsTestCase()
Constructor.
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:91
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite()
Constructor.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:97
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:849
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:675
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:825
ns3::tests::g_oneUniformRandomVariableManyGetValueCallsTestSuite
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:107
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
test-ns3.tests
tests
Definition:
test-ns3.py:2134
src
core
test
one-uniform-random-variable-many-get-value-calls-test-suite.cc
Generated on Tue Feb 6 2024 19:21:17 for ns-3 by
1.9.1