A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
assert-example.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Lawrence Livermore National Laboratory
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7 */
8
9/**
10 * \file
11 * \ingroup core-examples
12 * \ingroup assert
13 * Example program illustrating the use of NS_ASSERT_MSG()
14 */
15
16#include "ns3/core-module.h"
17
18#include <iostream>
19
20using namespace ns3;
21
22NS_LOG_COMPONENT_DEFINE("AssertExample");
23
24int
25main(int argc, char** argv)
26{
28 cmd.Parse(argc, argv);
29
30 std::cout << "NS_ASSERT_MSG example\n"
31 << " if an argument is given this example will assert.\n";
32
33 NS_ASSERT_MSG(argc == 1, "An argument was given, so we assert");
34
35 return 0;
36}
Parse command-line arguments.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Every class exported by the ns3 library is enclosed in the ns3 namespace.