A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
build-profile-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 LLNL
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7 */
8
9#include "ns3/build-profile.h"
10#include "ns3/test.h"
11
12/**
13 * @file
14 * @ingroup core-tests
15 * @ingroup debugging
16 * @ingroup build-profile-tests
17 * NS_BUILD_PROFILE macros test suite.
18 */
19
20/**
21 * @ingroup core-tests
22 * @defgroup build-profile-tests NS_BUILD_PROFILE macros test suite
23 */
24
25namespace ns3
26{
27
28namespace tests
29{
30
31/**
32 * @ingroup build-profile-tests
33 * Build profile test
34 */
36{
37 public:
39
41 {
42 }
43
44 private:
45 void DoRun() override;
46};
47
49 : TestCase("Check build profile macros")
50{
51}
52
53void
55{
56 int i = 0;
57 int j = 0;
58
59#ifdef NS3_BUILD_PROFILE_DEBUG
60 std::cout << GetName() << ": running in build profile debug" << std::endl;
61 NS_BUILD_DEBUG(++i; ++j);
62#elif NS3_BUILD_PROFILE_RELEASE
63 std::cout << GetName() << ": running in build profile release" << std::endl;
64 NS_BUILD_RELEASE(++i; ++j);
65#elif NS3_BUILD_PROFILE_OPTIMIZED
66 std::cout << GetName() << ": running in build profile optimized" << std::endl;
67 NS_BUILD_OPTIMIZED(++i; ++j);
68#else
69 NS_TEST_ASSERT_MSG_EQ(0, 1, ": no build profile case executed");
70#endif
71
72 if (i == 1)
73 {
74 std::cout << "build profile executed first statement." << std::endl;
75 }
76 NS_TEST_ASSERT_MSG_EQ(i, 1, "build profile failed to execute first statement");
77 if (j == 1)
78 {
79 std::cout << "build profile executed second statement." << std::endl;
80 }
81 NS_TEST_ASSERT_MSG_EQ(j, 1, "build profile failed to execute second statement");
82}
83
84/**
85 * @ingroup build-profile-tests
86 * Build profile test suite
87 */
89{
90 public:
92};
93
99
100/**
101 * @ingroup build-profile-tests
102 * BuildProfileTestSuite instance variable.
103 */
105
106} // namespace tests
107
108} // namespace ns3
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
std::string GetName() const
Definition test.cc:367
A suite of tests to run.
Definition test.h:1267
void DoRun() override
Implementation to actually run this TestCase.
static BuildProfileTestSuite g_BuildProfileTestSuite
BuildProfileTestSuite instance variable.
#define NS_BUILD_OPTIMIZED(code)
Execute a code snippet in optimized builds.
#define NS_BUILD_RELEASE(code)
Execute a code snippet in release builds.
#define NS_BUILD_DEBUG(code)
Execute a code snippet in debug builds.
#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:134
Every class exported by the ns3 library is enclosed in the ns3 namespace.