A Discrete-Event Network Simulator
API
assert-example.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Lawrence Livermore National Laboratory
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18  */
19 
27 #include "ns3/core-module.h"
28 
29 #include <iostream>
30 
31 using namespace ns3;
32 
33 NS_LOG_COMPONENT_DEFINE("AssertExample");
34 
35 int
36 main(int argc, char** argv)
37 {
39  cmd.Parse(argc, argv);
40 
41  std::cout << "NS_ASSERT_MSG example\n"
42  << " if an argument is given this example will assert.\n";
43 
44  NS_ASSERT_MSG(argc == 1, "An argument was given, so we assert");
45 
46  return 0;
47 }
Parse command-line arguments.
Definition: command-line.h:232
#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:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:40