A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
27
using namespace
ns3;
28
29
30
// ===========================================================================
31
// Test case for one uniform distribution random variable stream generator
32
// ===========================================================================
33
34
class
OneUniformRandomVariableManyGetValueCallsTestCase
:
public
TestCase
35
{
36
public
:
37
OneUniformRandomVariableManyGetValueCallsTestCase
();
38
virtual
~
OneUniformRandomVariableManyGetValueCallsTestCase
();
39
40
private
:
41
virtual
void
DoRun (
void
);
42
};
43
44
OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
()
45
:
TestCase
(
"One Uniform Random Variable with Many GetValue() Calls"
)
46
{
47
}
48
49
OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
()
50
{
51
}
52
53
void
54
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
(
void
)
55
{
56
double
min = 0.0;
57
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
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
class
OneUniformRandomVariableManyGetValueCallsTestSuite
:
public
TestSuite
77
{
78
public
:
79
OneUniformRandomVariableManyGetValueCallsTestSuite
();
80
};
81
82
OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
()
83
:
TestSuite
(
"one-uniform-random-variable-many-get-value-calls"
, PERFORMANCE)
84
{
85
AddTestCase
(
new
OneUniformRandomVariableManyGetValueCallsTestCase
, TestCase::QUICK);
86
}
87
88
static
OneUniformRandomVariableManyGetValueCallsTestSuite
oneUniformRandomVariableManyGetValueCallsTestSuite
;
ns3::Ptr< UniformRandomVariable >
OneUniformRandomVariableManyGetValueCallsTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:54
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
OneUniformRandomVariableManyGetValueCallsTestSuite
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:76
ns3::TestCase
encapsulates test code
Definition:
test.h:849
OneUniformRandomVariableManyGetValueCallsTestCase
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:34
OneUniformRandomVariableManyGetValueCallsTestSuite::OneUniformRandomVariableManyGetValueCallsTestSuite
OneUniformRandomVariableManyGetValueCallsTestSuite()
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:82
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:773
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition:
config.cc:667
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
Definition:
random-variable-stream.cc:174
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:173
oneUniformRandomVariableManyGetValueCallsTestSuite
static OneUniformRandomVariableManyGetValueCallsTestSuite oneUniformRandomVariableManyGetValueCallsTestSuite
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:88
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:688
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
OneUniformRandomVariableManyGetValueCallsTestCase::OneUniformRandomVariableManyGetValueCallsTestCase
OneUniformRandomVariableManyGetValueCallsTestCase()
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:44
OneUniformRandomVariableManyGetValueCallsTestCase::~OneUniformRandomVariableManyGetValueCallsTestCase
virtual ~OneUniformRandomVariableManyGetValueCallsTestCase()
Definition:
one-uniform-random-variable-many-get-value-calls-test-suite.cc:49
src
core
test
one-uniform-random-variable-many-get-value-calls-test-suite.cc
Generated on Sat Apr 19 2014 14:06:53 for ns-3 by
1.8.6