Function Macro

GLibassert_cmpmem

Declaration

#define g_assert_cmpmem (
  m1,
  l1,
  m2,
  l2
)

Description

Debugging macro to compare memory regions. If the comparison fails, an error message is logged and the application is either terminated or the testcase marked as failed.

The effect of g_assert_cmpmem (m1, l1, m2, l2) is the same as g_assert_true (l1 == l2 && memcmp (m1, m2, l1) == 0). The advantage of this macro is that it can produce a message that includes the actual values of l1 and l2.

m1 may be NULL if (and only if) l1 is zero; similarly for m2 and l2.

  g_assert_cmpmem (buf->data, buf->len, expected, sizeof (expected));
Available since:2.46

Parameters

m1 -
 

Pointer to a buffer.

l1 -
 

Length of m1

m2 -
 

Pointer to another buffer.

l2 -
 

Length of m2