File: bad-instance.h

package info (click to toggle)
phosh 0.53.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,936 kB
  • sloc: ansic: 83,383; xml: 3,981; python: 717; sh: 449; makefile: 34; lisp: 22; javascript: 6
file content (46 lines) | stat: -rw-r--r-- 1,489 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright © 2020 Zander Brown
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Author: Zander Brown <zbrown@gnome.org>
 */

#include <glib.h>

#ifdef G_LOG_STRUCTURED
# error G_LOG_STRUCTURED is set, g_test_expect_message is noop
#endif

/**
 * NULL_INSTANCE_CALL:
 * @func: the function to call
 * @msg: the failed assertion
 * @...: arguments to @func
 *
 * Attempt call @func on %NULL, expecting a log in @G_LOG_DOMAIN
 *
 * Used to check the call guards in methods
 */
#define NULL_INSTANCE_CALL(func, msg, ...)                                         \
  g_test_expect_message (G_LOG_DOMAIN,                                        \
                         G_LOG_LEVEL_CRITICAL,                                \
                         #func ": assertion '" msg "' failed");              \
  func (NULL, ##__VA_ARGS__);

/**
 * NULL_INSTANCE_CALL_RETURN:
 * @func: the function to call
 * @msg: the failed assertion
 * @ret: the return value expected
 * @...: arguments to @func
 *
 * Attempt call @func on %NULL, expecting a log in @G_LOG_DOMAIN
 *
 * Used to check the call guards in methods
 */
#define NULL_INSTANCE_CALL_RETURN(func, msg, ret, ...)                        \
  g_test_expect_message (G_LOG_DOMAIN,                                        \
                         G_LOG_LEVEL_CRITICAL,                                \
                         #func ": assertion '" msg "' failed");              \
  g_assert_true (func (NULL, ##__VA_ARGS__) == ret);