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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mitch Watrous (watrous@u.washington.edu)
7
*/
8
9
#include "ns3/config.h"
10
#include "ns3/double.h"
11
#include "ns3/random-variable-stream.h"
12
#include "ns3/test.h"
13
14
/**
15
* @file
16
* @ingroup core-tests
17
* @ingroup randomvariable
18
* @ingroup rng-tests
19
* Test for one uniform random variable stream.
20
*/
21
22
namespace
ns3
23
{
24
25
namespace
tests
26
{
27
28
/**
29
* @ingroup rng-tests
30
* Test case for one uniform distribution random variable stream generator
31
*/
32
class
OneUniformRandomVariableManyGetValueCallsTestCase
:
public
TestCase
33
{
34
public
:
35
OneUniformRandomVariableManyGetValueCallsTestCase
();
36
~OneUniformRandomVariableManyGetValueCallsTestCase
()
override
;
37
38
private
:
39
void
DoRun
()
override
;
40
};
41
42
OneUniformRandomVariableManyGetValueCallsTestCase::
43
OneUniformRandomVariableManyGetValueCallsTestCase
()
44
:
TestCase
(
"One Uniform Random Variable with Many GetValue() Calls"
)
45
{
46
}
47
48
OneUniformRandomVariableManyGetValueCallsTestCase::
49
~OneUniformRandomVariableManyGetValueCallsTestCase
()
50
{
51
}
52
53
void
54
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
()
55
{
56
const
double
min = 0.0;
57
const
double
max = 10.0;
58
59
Config::SetDefault
(
"ns3::UniformRandomVariable::Min"
,
DoubleValue
(min));
60
Config::SetDefault
(
"ns3::UniformRandomVariable::Max"
,
DoubleValue
(max));
61
62
Ptr<UniformRandomVariable>
uniform =
CreateObject<UniformRandomVariable>
();
63
64
// Get many values from 1 random number generator.
65
double
value;
66
const
int
count = 100000000;
67
for
(
int
i = 0; i < count; i++)
68
{
69
value = uniform->GetValue();
70
71
NS_TEST_ASSERT_MSG_GT
(value, min,
"Value less than minimum."
);
72
NS_TEST_ASSERT_MSG_LT
(value, max,
"Value greater than maximum."
);
73
}
74
}
75
76
/**
77
* @ingroup rng-tests
78
* Test suite for one uniform distribution random variable stream generator
79
*/
80
class
OneUniformRandomVariableManyGetValueCallsTestSuite
:
public
TestSuite
81
{
82
public
:
83
OneUniformRandomVariableManyGetValueCallsTestSuite
();
84
};
85
86
OneUniformRandomVariableManyGetValueCallsTestSuite::
87
OneUniformRandomVariableManyGetValueCallsTestSuite
()
88
:
TestSuite
(
"one-uniform-random-variable-many-get-value-calls"
,
Type
::PERFORMANCE)
89
{
90
AddTestCase
(
new
OneUniformRandomVariableManyGetValueCallsTestCase
);
91
}
92
93
/**
94
* @ingroup rng-tests
95
* OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
96
*/
97
static
OneUniformRandomVariableManyGetValueCallsTestSuite
98
g_oneUniformRandomVariableManyGetValueCallsTestSuite
;
99
100
}
// namespace tests
101
102
}
// namespace ns3
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:296
ns3::TestCase::TestCase
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1271
ns3::TestSuite::TestSuite
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition
test.cc:494
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:33
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
~OneUniformRandomVariableManyGetValueCallsTestCase() override
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:49
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:54
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
OneUniformRandomVariableManyGetValueCallsTestCase()
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:43
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:81
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite()
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:87
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition
config.cc:886
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:627
ns3::tests::g_oneUniformRandomVariableManyGetValueCallsTestSuite
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:98
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:698
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:863
ns3::tests
Namespace for test files, TestCases and TestSuites.
Definition
environment-variable.h:32
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
for ns-3 by
1.15.0