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
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
* 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 many uniform random variable streams.
22
*/
23
24
namespace
ns3
25
{
26
27
namespace
tests
28
{
29
30
/**
31
* \ingroup rng-tests
32
* Test case for many uniform distribution random variable stream generators
33
*/
34
class
ManyUniformRandomVariablesOneGetValueCallTestCase
:
public
TestCase
35
{
36
public
:
37
ManyUniformRandomVariablesOneGetValueCallTestCase
();
38
~ManyUniformRandomVariablesOneGetValueCallTestCase
()
override
;
39
40
private
:
41
void
DoRun
()
override
;
42
};
43
44
ManyUniformRandomVariablesOneGetValueCallTestCase::
45
ManyUniformRandomVariablesOneGetValueCallTestCase
()
46
:
TestCase
(
"Many Uniform Random Variables with One GetValue() Call"
)
47
{
48
}
49
50
ManyUniformRandomVariablesOneGetValueCallTestCase::
51
~ManyUniformRandomVariablesOneGetValueCallTestCase
()
52
{
53
}
54
55
void
56
ManyUniformRandomVariablesOneGetValueCallTestCase::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
// Get 1 value from many uniform random number generators.
65
double
value;
66
const
int
count = 1000000;
67
std::vector<Ptr<UniformRandomVariable>> uniformStreamVector(count);
68
for
(
int
i = 0; i < count; i++)
69
{
70
uniformStreamVector.push_back(
CreateObject<UniformRandomVariable>
());
71
value = uniformStreamVector.back()->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 many uniform distribution random variable stream generators
81
*/
82
class
ManyUniformRandomVariablesOneGetValueCallTestSuite
:
public
TestSuite
83
{
84
public
:
85
ManyUniformRandomVariablesOneGetValueCallTestSuite
();
86
};
87
88
ManyUniformRandomVariablesOneGetValueCallTestSuite::
89
ManyUniformRandomVariablesOneGetValueCallTestSuite
()
90
:
TestSuite
(
"many-uniform-random-variables-one-get-value-call"
,
Type
::PERFORMANCE)
91
{
92
AddTestCase
(
new
ManyUniformRandomVariablesOneGetValueCallTestCase
);
93
}
94
95
/**
96
* \ingroup rng-tests
97
* ManuUniformRandomVariablesOneGetValueCallTestSuite instance variable.
98
*/
99
static
ManyUniformRandomVariablesOneGetValueCallTestSuite
100
g_manyUniformRandomVariablesOneGetValueCallTestSuite
;
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::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::ManyUniformRandomVariablesOneGetValueCallTestCase
Test case for many uniform distribution random variable stream generators.
Definition
many-uniform-random-variables-one-get-value-call-test-suite.cc:35
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::ManyUniformRandomVariablesOneGetValueCallTestCase
ManyUniformRandomVariablesOneGetValueCallTestCase()
Definition
many-uniform-random-variables-one-get-value-call-test-suite.cc:45
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:56
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::~ManyUniformRandomVariablesOneGetValueCallTestCase
~ManyUniformRandomVariablesOneGetValueCallTestCase() override
Definition
many-uniform-random-variables-one-get-value-call-test-suite.cc:51
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:83
ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestSuite::ManyUniformRandomVariablesOneGetValueCallTestSuite
ManyUniformRandomVariablesOneGetValueCallTestSuite()
Definition
many-uniform-random-variables-one-get-value-call-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_manyUniformRandomVariablesOneGetValueCallTestSuite
static ManyUniformRandomVariablesOneGetValueCallTestSuite g_manyUniformRandomVariablesOneGetValueCallTestSuite
ManuUniformRandomVariablesOneGetValueCallTestSuite instance variable.
Definition
many-uniform-random-variables-one-get-value-call-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
many-uniform-random-variables-one-get-value-call-test-suite.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0