mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-01 04:18:05 -05:00
Merge branch 'wip/smcv/assert-true-false' into 'master'
backport-testutils: Add g_assert_true(), g_assert_false() See merge request GNOME/libglnx!44
This commit is contained in:
@@ -34,6 +34,14 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef g_assert_true /* added in 2.38 */
|
||||
#define g_assert_true(x) g_assert ((x))
|
||||
#endif
|
||||
|
||||
#ifndef g_assert_false /* added in 2.38 */
|
||||
#define g_assert_false(x) g_assert (!(x))
|
||||
#endif
|
||||
|
||||
#ifndef g_assert_nonnull /* added in 2.40 */
|
||||
#define g_assert_nonnull(x) g_assert (x != NULL)
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,8 @@ test_assertions (void)
|
||||
const char * const strv2[] = {"one", "two", NULL};
|
||||
GStatBuf statbuf;
|
||||
|
||||
g_assert_true (null == NULL);
|
||||
g_assert_false (null != NULL);
|
||||
g_assert_null (null);
|
||||
g_assert_nonnull (nonnull);
|
||||
g_assert_cmpmem (null, 0, null, 0);
|
||||
@@ -64,6 +66,8 @@ test_assertion_failures (void)
|
||||
{
|
||||
static const char * const assertion_failures[] =
|
||||
{
|
||||
"true",
|
||||
"false",
|
||||
"nonnull",
|
||||
"null",
|
||||
"mem_null_nonnull",
|
||||
|
||||
@@ -48,6 +48,18 @@ test_messages (void)
|
||||
"That's why libglnx provides a wrapper.\n");
|
||||
}
|
||||
|
||||
static void
|
||||
test_assertion_failure_true (void)
|
||||
{
|
||||
g_assert_true (null != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_assertion_failure_false (void)
|
||||
{
|
||||
g_assert_false (null == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_assertion_failure_nonnull (void)
|
||||
{
|
||||
@@ -303,6 +315,8 @@ main (int argc,
|
||||
{
|
||||
/* Use -p to select a specific one of these */
|
||||
#define T(x) g_test_add_func ("/assertion-failure/" #x, test_assertion_failure_ ## x)
|
||||
T (true);
|
||||
T (false);
|
||||
T (nonnull);
|
||||
T (null);
|
||||
T (mem_null_nonnull);
|
||||
|
||||
Reference in New Issue
Block a user