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
global-value-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) 2008 INRIA
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
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "ns3/global-value.h"
21
#include "ns3/test.h"
22
#include "ns3/uinteger.h"
23
24
namespace
ns3 {
25
26
// ===========================================================================
27
// Test for the ability to get at a GlobalValue.
28
// ===========================================================================
29
class
GlobalValueTestCase
:
public
TestCase
30
{
31
public
:
32
GlobalValueTestCase
();
33
virtual
~GlobalValueTestCase
() {}
34
35
private
:
36
virtual
void
DoRun
(
void
);
37
};
38
39
GlobalValueTestCase::GlobalValueTestCase
()
40
:
TestCase
(
"Check GlobalValue mechanism"
)
41
{
42
}
43
44
void
45
GlobalValueTestCase::DoRun
(
void
)
46
{
47
//
48
// Typically these are static globals but we can make one on the stack to
49
// keep it hidden from the documentation.
50
//
51
GlobalValue
uint =
GlobalValue
(
"TestUint"
,
"help text"
,
52
UintegerValue
(10),
53
MakeUintegerChecker<uint32_t> ());
54
55
//
56
// Make sure we can get at the value and that it was initialized correctly.
57
//
58
UintegerValue
uv;
59
uint.
GetValue
(uv);
60
NS_TEST_ASSERT_MSG_EQ
(uv.
Get
(), 10,
"GlobalValue \"TestUint\" not initialized as expected"
);
61
62
//
63
// Remove the global value for a valgrind clean run
64
//
65
GlobalValue::Vector
*vector =
GlobalValue::GetVector
();
66
for
(GlobalValue::Vector::iterator i = vector->begin (); i != vector->end (); ++i)
67
{
68
if
((*i) == &uint)
69
{
70
vector->erase (i);
71
break
;
72
}
73
}
74
}
75
76
// ===========================================================================
77
// The Test Suite that glues all of the Test Cases together.
78
// ===========================================================================
79
class
GlobalValueTestSuite
:
public
TestSuite
80
{
81
public
:
82
GlobalValueTestSuite
();
83
};
84
85
GlobalValueTestSuite::GlobalValueTestSuite
()
86
:
TestSuite
(
"global-value"
, UNIT)
87
{
88
AddTestCase
(
new
GlobalValueTestCase
,
TestCase::QUICK
);
89
}
90
91
static
GlobalValueTestSuite
globalValueTestSuite
;
92
93
}
// namespace ns3
94
ns3::globalValueTestSuite
static GlobalValueTestSuite globalValueTestSuite
Definition:
global-value-test-suite.cc:91
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
ns3::TestCase
encapsulates test code
Definition:
test.h:849
ns3::GlobalValue
hold a so-called 'global value'.
Definition:
global-value.h:47
ns3::GlobalValue::GetVector
static Vector * GetVector(void)
Definition:
global-value.cc:228
ns3::UintegerValue::Get
uint64_t Get(void) const
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:46
ns3::GlobalValue::Vector
std::vector< GlobalValue * > Vector
Definition:
global-value.h:49
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:173
ns3::TestCase::QUICK
Fast test.
Definition:
test.h:857
ns3::GlobalValueTestCase::GlobalValueTestCase
GlobalValueTestCase()
Definition:
global-value-test-suite.cc:39
ns3::GlobalValueTestSuite
Definition:
global-value-test-suite.cc:79
ns3::GlobalValueTestSuite::GlobalValueTestSuite
GlobalValueTestSuite()
Definition:
global-value-test-suite.cc:85
ns3::GlobalValueTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
global-value-test-suite.cc:45
ns3::GlobalValueTestCase
Definition:
global-value-test-suite.cc:29
ns3::GlobalValue::GetValue
void GetValue(AttributeValue &value) const
Definition:
global-value.cc:112
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition:
test.h:137
ns3::GlobalValueTestCase::~GlobalValueTestCase
virtual ~GlobalValueTestCase()
Definition:
global-value-test-suite.cc:33
src
core
test
global-value-test-suite.cc
Generated on Sat Apr 19 2014 14:06:53 for ns-3 by
1.8.6