VirtualBox

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

Last change on this file since 98172 was 98172, checked in by vboxsync, 20 months ago

Devices/Network: Wrapped the cppunit tests tstDevEEPROM and tstDevPhy to IPRT testing.

  • 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 98172 2023-01-21 13:01:48Z 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
29#ifndef VBOX_INCLUDED_SRC_Network_testcase_CppUnitEmulation_h
30#define VBOX_INCLUDED_SRC_Network_testcase_CppUnitEmulation_h
31#ifndef RT_WITHOUT_PRAGMA_ONCE
32# pragma once
33#endif
34
35#include <iprt/test.h>
36
37#define CPPUNIT_TEST_SUITE(a_Name) \
38public: \
39 RTEXITCODE run(void) \
40 { \
41 RTTEST hTest = NIL_RTTEST; \
42 RTEXITCODE rcExit = RTTestInitAndCreate(#a_Name, &hTest); \
43 if (rcExit == RTEXITCODE_SUCCESS) \
44 { \
45 RTTestBanner(hTest)
46
47#define CPPUNIT_TEST(a_MethodName) \
48 RTTestISub(#a_MethodName); \
49 setUp(); \
50 a_MethodName(); \
51 tearDown()
52
53#define CPPUNIT_TEST_SUITE_END() \
54 rcExit = RTTestSummaryAndDestroy(hTest); \
55 } \
56 return rcExit; \
57 } \
58 typedef int dummy_end
59
60#define CPPUNIT_FAIL(a_Msg) RTTestIFailed(a_Msg)
61#if __cplusplus+0 < 201100
62# define CPPUNIT_ASSERT_EQUAL(a_Value1, a_Value2) RTTESTI_CHECK((a_Value1) == (a_Value2))
63#else
64# define CPPUNIT_ASSERT_EQUAL(a_Value1, a_Value2) do { \
65 auto const Val1 = (a_Value1); \
66 auto const Val2 = (a_Value2); \
67 if (Val1 != Val2) \
68 RTTestIFailed("%s (%#llx) != %s (%#llx)", #a_Value1, (uint64_t)Val1, #a_Value2, (uint64_t)Val2); \
69 } while (0)
70#endif
71
72#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