VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/testcase/CppUnitEmulation.h@ 103068

Last change on this file since 103068 was 98174, checked in by vboxsync, 22 months ago

Devices/Network: Wrapped the cppunit tests tstDevEEPROM and tstDevPhy to IPRT testing. [scm fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: CppUnitEmulation.h 98174 2023-01-21 13:23:05Z vboxsync $ */
2/** @file
3 * Simple cppunit emulation
4 */
5
6/*
7 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_Network_testcase_CppUnitEmulation_h
29#define VBOX_INCLUDED_SRC_Network_testcase_CppUnitEmulation_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/test.h>
35
36#define CPPUNIT_TEST_SUITE(a_Name) \
37public: \
38 RTEXITCODE run(void) \
39 { \
40 RTTEST hTest = NIL_RTTEST; \
41 RTEXITCODE rcExit = RTTestInitAndCreate(#a_Name, &hTest); \
42 if (rcExit == RTEXITCODE_SUCCESS) \
43 { \
44 RTTestBanner(hTest)
45
46#define CPPUNIT_TEST(a_MethodName) \
47 RTTestISub(#a_MethodName); \
48 setUp(); \
49 a_MethodName(); \
50 tearDown()
51
52#define CPPUNIT_TEST_SUITE_END() \
53 rcExit = RTTestSummaryAndDestroy(hTest); \
54 } \
55 return rcExit; \
56 } \
57 typedef int dummy_end
58
59#define CPPUNIT_FAIL(a_Msg) RTTestIFailed(a_Msg)
60#if __cplusplus+0 < 201100
61# define CPPUNIT_ASSERT_EQUAL(a_Value1, a_Value2) RTTESTI_CHECK((a_Value1) == (a_Value2))
62#else
63# define CPPUNIT_ASSERT_EQUAL(a_Value1, a_Value2) do { \
64 auto const Val1 = (a_Value1); \
65 auto const Val2 = (a_Value2); \
66 if (Val1 != Val2) \
67 RTTestIFailed("%s (%#llx) != %s (%#llx)", #a_Value1, (uint64_t)Val1, #a_Value2, (uint64_t)Val2); \
68 } while (0)
69#endif
70
71#endif /* !VBOX_INCLUDED_SRC_Network_testcase_CppUnitEmulation_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette