4 * Copyright (C) 2011 Stefan Walter
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * Author: Stef Walter <stefw@collabora.co.uk>
24 #ifndef EGG_TESTING_H_
25 #define EGG_TESTING_H_
30 #define egg_assert_cmpsize(a, o, b) \
31 g_assert_cmpuint ((guint)(a), o, (guint)(b))
33 #define egg_assert_cmpmem(a, na, cmp, b, nb) \
34 do { gconstpointer __p1 = (a), __p2 = (b); gsize __n1 = (na), __n2 = (nb); \
35 if (__n1 cmp __n2 && memcmp (__p1, __p2, __n1) cmp 0) ; else \
36 egg_assertion_message_cmpmem (G_LOG_DOMAIN, __FILE__, __LINE__, \
37 G_STRFUNC, #a "[" #na"] " #cmp " " #b "[" #nb "]", \
38 __p1, __n1, #cmp, __p2, __n2); } while (0)
40 #define egg_assert_not_object(p) \
41 (egg_assertion_not_object (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #p, (p)))
43 void egg_assertion_not_object (const char *domain,
50 void egg_assertion_message_cmpmem (const char *domain, const char *file,
51 int line, const char *func,
52 const char *expr, gconstpointer arg1,
53 gsize n_arg1, const char *cmp,
54 gconstpointer arg2, gsize n_arg2);
56 void egg_test_wait_stop (void);
58 #define egg_test_wait() g_assert (egg_test_wait_until (20000) != FALSE)
60 gboolean egg_test_wait_until (int timeout);
62 gint egg_tests_run_with_loop (void);
64 #endif /* EGG_DH_H_ */