This documentation is not the
Latest Release
.
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
build-profile-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) 2015 LLNL
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: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19
*/
20
21
#include "ns3/build-profile.h"
22
#include "ns3/test.h"
23
24
using namespace
ns3
;
25
26
class
BuildProfileTestCase
:
public
TestCase
27
{
28
public
:
29
BuildProfileTestCase
();
30
virtual
~BuildProfileTestCase
() {}
31
32
private
:
33
virtual
void
DoRun (
void
);
34
};
35
36
BuildProfileTestCase::BuildProfileTestCase
(
void
)
37
:
TestCase
(
"Check build profile macros"
)
38
{
39
}
40
41
void
42
BuildProfileTestCase::DoRun
(
void
)
43
{
44
int
i = 0;
45
int
j = 0;
46
47
#ifdef NS3_BUILD_PROFILE_DEBUG
48
std::cout <<
GetName
() <<
": running in build profile debug"
<< std::endl;
49
NS_BUILD_DEBUG
(++i; ++j);
50
#elif NS3_BUILD_PROFILE_RELEASE
51
std::cout <<
GetName
() <<
": running in build profile release"
<< std::endl;
52
NS_BUILD_RELEASE
(++i; ++j);
53
#elif NS3_BUILD_PROFILE_OPTIMIZED
54
std::cout <<
GetName
() <<
": running in build profile optimized"
<< std::endl;
55
NS_BUILD_OPTIMIZED
(++i; ++j);
56
#else
57
NS_TEST_ASSERT_MSG_EQ
(0, 1,
": no build profile case executed"
);
58
#endif
59
60
if
(i == 1)
61
std::cout <<
"build profile executed first statement."
<< std::endl;
62
NS_TEST_ASSERT_MSG_EQ
(i, 1,
63
"build profile failed to execute first statement"
);
64
if
(j == 1)
65
std::cout <<
"build profile executed second statement."
<< std::endl;
66
NS_TEST_ASSERT_MSG_EQ
(j, 1,
67
"build profile failed to execute second statement"
);
68
}
69
70
class
BuildProfileTestSuite
:
public
TestSuite
71
{
72
public
:
73
BuildProfileTestSuite
();
74
};
75
76
BuildProfileTestSuite::BuildProfileTestSuite
()
77
:
TestSuite
(
"build-profile"
, UNIT)
78
{
79
AddTestCase
(
new
BuildProfileTestCase
, TestCase::QUICK);
80
}
81
82
static
BuildProfileTestSuite
g_BuildProfileTestSuite
;
BuildProfileTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
build-profile-test-suite.cc:42
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1333
BuildProfileTestSuite
Definition:
build-profile-test-suite.cc:70
ns3::TestCase
encapsulates test code
Definition:
test.h:1147
g_BuildProfileTestSuite
static BuildProfileTestSuite g_BuildProfileTestSuite
Definition:
build-profile-test-suite.cc:82
NS_BUILD_RELEASE
#define NS_BUILD_RELEASE(code)
Execute a code snippet in release builds.
Definition:
build-profile.h:74
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition:
test.cc:297
BuildProfileTestCase::BuildProfileTestCase
BuildProfileTestCase()
Definition:
build-profile-test-suite.cc:36
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:161
NS_BUILD_OPTIMIZED
#define NS_BUILD_OPTIMIZED(code)
Execute a code snippet in optimized builds.
Definition:
build-profile.h:85
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
BuildProfileTestCase::~BuildProfileTestCase
virtual ~BuildProfileTestCase()
Definition:
build-profile-test-suite.cc:30
NS_BUILD_DEBUG
#define NS_BUILD_DEBUG(code)
Execute a code snippet in debug builds.
Definition:
build-profile.h:63
ns3::TestCase::GetName
std::string GetName(void) const
Definition:
test.cc:368
BuildProfileTestCase
Definition:
build-profile-test-suite.cc:26
BuildProfileTestSuite::BuildProfileTestSuite
BuildProfileTestSuite()
Definition:
build-profile-test-suite.cc:76
src
core
test
build-profile-test-suite.cc
Generated on Wed Nov 11 2015 20:00:28 for ns-3 by
1.8.9.1