A Discrete-Event Network Simulator
API
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 
37 namespace ns3 {
38 
39  namespace tests {
40 
41 
47 {
48 public:
50  virtual ~BuildProfileTestCase () {}
51 
52 private:
53  virtual void DoRun (void);
54 };
55 
57  : TestCase ("Check build profile macros")
58 {
59 }
60 
61 void
63 {
64  int i = 0;
65  int j = 0;
66 
67 #ifdef NS3_BUILD_PROFILE_DEBUG
68  std::cout << GetName () << ": running in build profile debug" << std::endl;
69  NS_BUILD_DEBUG (++i; ++j);
70 #elif NS3_BUILD_PROFILE_RELEASE
71  std::cout << GetName () << ": running in build profile release" << std::endl;
72  NS_BUILD_RELEASE (++i; ++j);
73 #elif NS3_BUILD_PROFILE_OPTIMIZED
74  std::cout << GetName () << ": running in build profile optimized" << std::endl;
75  NS_BUILD_OPTIMIZED (++i; ++j);
76 #else
77  NS_TEST_ASSERT_MSG_EQ (0, 1, ": no build profile case executed");
78 #endif
79 
80  if (i == 1)
81  std::cout << "build profile executed first statement." << std::endl;
83  "build profile failed to execute first statement");
84  if (j == 1)
85  std::cout << "build profile executed second statement." << std::endl;
87  "build profile failed to execute second statement");
88 }
89 
95 {
96 public:
98 };
99 
101  : TestSuite ("build-profile")
102 {
104 }
105 
111 
112 
113  } // namespace tests
114 
115 } // namespace ns3
A suite of tests to run.
Definition: test.h:1342
encapsulates test code
Definition: test.h:1155
#define NS_BUILD_RELEASE(code)
Execute a code snippet in release builds.
Definition: build-profile.h:74
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
#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:168
static BuildProfileTestSuite g_BuildProfileTestSuite
BuildProfileTestSuite instance variable.
#define NS_BUILD_OPTIMIZED(code)
Execute a code snippet in optimized builds.
Definition: build-profile.h:85
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetName(void) const
Definition: test.cc:370
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_BUILD_DEBUG(code)
Execute a code snippet in debug builds.
Definition: build-profile.h:63