QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mock.h
Go to the documentation of this file.
1 
14 #include "qev.h"
15 
16 #ifndef QEV_ENABLE_MOCK
17 
21 #define QEV_MOCK(fn_ret, fn, ...) fn(__VA_ARGS__)
22 
23 #else
24 
28 #define QEV_MOCK(fn_ret, fn, ...) \
29  ({ \
30  fn_ret ret; \
31  if (_qev_mock_is_mocked(__func__, G_STRINGIFY(fn))) { \
32  ret = (fn_ret)_qev_mock_run(__func__, G_STRINGIFY(fn), \
33  ## __VA_ARGS__); \
34  } else { \
35  ret = (fn_ret)fn(__VA_ARGS__); \
36  } \
37  ret; \
38  })
39 
40 #endif
41 
48 typedef guint64 (*qev_mock_cb)(va_list args);
49 
68 void qev_mock_add(
69  const gchar *parent,
70  const gchar *fn,
71  const guint64 ret,
72  const qev_mock_cb cb,
73  const gint err);
74 
79 gboolean _qev_mock_is_mocked(const gchar *parent, const gchar *fn);
80 
85 guint64 _qev_mock_run(const gchar *parent, const gchar *fn, ...);
86 
94 void qev_mock_done();
void qev_mock_done()
Clears all the mocks.
guint64(* qev_mock_cb)(va_list args)
Function type for callbacks from mocks.
Definition: mock.h:48
Provides all the qev_* functions that are needed for creating an event loop.
void qev_mock_add(const gchar *parent, const gchar *fn, const guint64 ret, const qev_mock_cb cb, const gint err)
Adds a mock to the current run suite.