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
histogram-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) 2009 INESC Porto
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: Pedro Fortuna <pedro.fortuna@inescporto.pt> <pedro.fortuna@gmail.com>
19
//
20
21
#include "ns3/histogram.h"
22
#include "ns3/test.h"
23
24
namespace
ns3 {
25
26
class
HistogramTestCase
:
public
ns3::TestCase
{
27
private
:
28
public
:
29
HistogramTestCase
();
30
virtual
void
DoRun
(
void
);
31
32
33
};
34
35
HistogramTestCase::HistogramTestCase
()
36
: ns3::
TestCase
(
"Histogram"
)
37
{
38
}
39
40
41
void
42
HistogramTestCase::DoRun
(
void
)
43
{
44
Histogram
h0 (3.5);
45
// Testing floating-point bin widths
46
{
47
for
(
int
i=1; i <= 10; i++)
48
{
49
h0.
AddValue
(3.4);
50
}
51
52
for
(
int
i=1; i <= 5; i++)
53
{
54
h0.
AddValue
(3.6);
55
}
56
57
NS_TEST_EXPECT_MSG_EQ_TOL
(h0.
GetBinWidth
(0), 3.5, 1e-6,
""
);
58
NS_TEST_EXPECT_MSG_EQ
(h0.
GetNBins
(), 2,
""
);
59
NS_TEST_EXPECT_MSG_EQ_TOL
(h0.
GetBinStart
(1), 3.5, 1e-6,
""
);
60
NS_TEST_EXPECT_MSG_EQ
(h0.
GetBinCount
(0), 10,
""
);
61
NS_TEST_EXPECT_MSG_EQ
(h0.
GetBinCount
(1), 5,
""
);
62
}
63
64
{
65
// Testing bin expansion
66
h0.
AddValue
(74.3);
67
NS_TEST_EXPECT_MSG_EQ
(h0.
GetNBins
(), 22,
""
);
68
NS_TEST_EXPECT_MSG_EQ
(h0.
GetBinCount
(21), 1,
""
);
69
}
70
}
71
72
static
class
HistogramTestSuite
:
public
TestSuite
73
{
74
public
:
75
HistogramTestSuite
()
76
:
TestSuite
(
"histogram"
,
UNIT
)
77
{
78
AddTestCase
(
new
HistogramTestCase
());
79
}
80
}
g_HistogramTestSuite
;
81
82
}
// namespace
83
84
src
flow-monitor
test
histogram-test-suite.cc
Generated on Tue Nov 13 2012 10:32:13 for ns-3 by
1.8.1.2