summaryrefslogtreecommitdiff
path: root/tests/internal-debug.c
blob: 894924920d7fdd09965a5cf980ba2da2b09004b8 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include <glib.h>

#include <telepathy-glib/debug.h>

#undef DEBUG_FLAG
#define DEBUG_FLAG TP_DEBUG_IM
#include "telepathy-glib/debug-internal.h"

static void
test_debugging (void)
{
  DEBUG ("internal-debug.h should always define DEBUG %s",
    "(either as a macro or as a no-op static inline function");

#ifndef DEBUGGING
#error internal-debug.h should always define DEBUGGING
#endif

#ifdef ENABLE_DEBUG
  g_assert (DEBUGGING == 1);
#else
  g_assert (DEBUGGING == 0);
#endif
}

#undef DEBUG_FLAG
#define DEBUG_FLAG TP_DEBUG_CONNECTION
#include "telepathy-glib/debug-internal.h"

static void
test_not_debugging (void)
{
  DEBUG ("internal-debug.h should always define DEBUG %s",
    "(either as a macro or as a no-op static inline function");

#ifndef DEBUGGING
#error internal-debug.h should always define DEBUGGING
#endif

  g_assert (DEBUGGING == 0);
}

#undef DEBUG_FLAG
#define DEBUG_FLAG TP_DEBUG_IM
#include "telepathy-glib/debug-internal.h"

static void
test_debugging_again (void)
{
  DEBUG ("internal-debug.h should always define DEBUG %s",
    "(either as a macro or as a no-op static inline function");

#ifndef DEBUGGING
#error internal-debug.h should always define DEBUGGING
#endif

#ifdef ENABLE_DEBUG
  g_assert (DEBUGGING == 1);
#else
  g_assert (DEBUGGING == 0);
#endif
}

int
main (int argc, char **argv)
{
  /* We enable debugging for IM, but not for the connection. */
  tp_debug_set_flags ("im");
  test_debugging ();
  test_not_debugging ();
  test_debugging_again ();
  return 0;
}