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
#include <vector>
15
16
/**
17
* \file
18
* \ingroup core-tests
19
* \ingroup randomvariable
20
* \ingroup rng-tests
21
* Test for one uniform random variable stream.
22
*/
23
24
namespace
ns3
25
{
26
27
namespace
tests
28
{
29
30
/**
31
* \ingroup rng-tests
32
* Test case for one uniform distribution random variable stream generator
33
*/
34
class
OneUniformRandomVariableManyGetValueCallsTestCase
:
public
TestCase
35
{
36
public
:
37
OneUniformRandomVariableManyGetValueCallsTestCase
();
38
~OneUniformRandomVariableManyGetValueCallsTestCase
()
override
;
39
40
private
:
41
void
DoRun
()
override
;
42
};
43
44
OneUniformRandomVariableManyGetValueCallsTestCase::
45
OneUniformRandomVariableManyGetValueCallsTestCase
()
46
:
TestCase
(
"One Uniform Random Variable with Many GetValue() Calls"
)
47
{
48
}
49
50
OneUniformRandomVariableManyGetValueCallsTestCase::
51
~OneUniformRandomVariableManyGetValueCallsTestCase
()
52
{
53
}
54
55
void
56
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
()
57
{
58
const
double
min = 0.0;
59
const
double
max = 10.0;
60
61
Config::SetDefault
(
"ns3::UniformRandomVariable::Min"
,
DoubleValue
(min));
62
Config::SetDefault
(
"ns3::UniformRandomVariable::Max"
,
DoubleValue
(max));
63
64
Ptr<UniformRandomVariable>
uniform =
CreateObject<UniformRandomVariable>
();
65
66
// Get many values from 1 random number generator.
67
double
value;
68
const
int
count = 100000000;
69
for
(
int
i = 0; i < count; i++)
70
{
71
value = uniform->GetValue();
72
73
NS_TEST_ASSERT_MSG_GT
(value, min,
"Value less than minimum."
);
74
NS_TEST_ASSERT_MSG_LT
(value, max,
"Value greater than maximum."
);
75
}
76
}
77
78
/**
79
* \ingroup rng-tests
80
* Test suite for one uniform distribution random variable stream generator
81
*/
82
class
OneUniformRandomVariableManyGetValueCallsTestSuite
:
public
TestSuite
83
{
84
public
:
85
OneUniformRandomVariableManyGetValueCallsTestSuite
();
86
};
87
88
OneUniformRandomVariableManyGetValueCallsTestSuite::
89
OneUniformRandomVariableManyGetValueCallsTestSuite
()
90
:
TestSuite
(
"one-uniform-random-variable-many-get-value-calls"
,
Type
::PERFORMANCE)
91
{
92
AddTestCase
(
new
OneUniformRandomVariableManyGetValueCallsTestCase
);
93
}
94
95
/**
96
* \ingroup rng-tests
97
* OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
98
*/
99
static
OneUniformRandomVariableManyGetValueCallsTestSuite
100
g_oneUniformRandomVariableManyGetValueCallsTestSuite
;
101
102
}
// namespace tests
103
104
}
// 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
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
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:35
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
~OneUniformRandomVariableManyGetValueCallsTestCase() override
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:51
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:56
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
OneUniformRandomVariableManyGetValueCallsTestCase()
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:45
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:83
ns3::tests::OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite()
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:89
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition
config.cc:883
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
ns3::tests::g_oneUniformRandomVariableManyGetValueCallsTestSuite
static OneUniformRandomVariableManyGetValueCallsTestSuite g_oneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite instance variable.
Definition
one-uniform-random-variable-many-get-value-calls-test-suite.cc:100
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:699
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:864
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 Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0