A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ascii-test.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mitch Watrous (watrous@u.washington.edu)
7 *
8 * This file is based on pcap-test.h by Craig Dowell (craigdo@ee.washington.edu)
9 */
10
11#ifndef ASCII_TEST_H
12#define ASCII_TEST_H
13
14#include "ascii-file.h"
15#include "test.h"
16
17#include <filesystem>
18#include <stdint.h>
19
20/**
21 * @brief Test that a pair of new/reference ascii files are equal
22 *
23 * @param gotFilename The name of the new file to read in including
24 * its path
25 * @param expectedFilename The name of the reference file to read in
26 * including its path
27 */
28#define NS_ASCII_TEST_EXPECT_EQ(gotFilename, expectedFilename) \
29 do \
30 { \
31 uint64_t line(0); \
32 bool fileExists = std::filesystem::exists(expectedFilename); \
33 if (fileExists) \
34 { \
35 bool diff = AsciiFile::Diff(gotFilename, expectedFilename, line); \
36 NS_TEST_EXPECT_MSG_EQ(diff, \
37 false, \
38 "ASCII traces " << gotFilename << " and " << expectedFilename \
39 << " differ starting from line " << line); \
40 } \
41 else \
42 { \
43 NS_TEST_EXPECT_MSG_EQ(fileExists, true, "File " << expectedFilename << " not found"); \
44 } \
45 } while (false)
46
47#endif /* ASCII_TEST_H */
ns3::TestCase, ns3::TestSuite, ns3::TestRunner declarations, and NS_TEST_ASSERT macro definitions.