tests: Use g_assert_*() rather than g_assert() in stream-rw_all tests

It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
This commit is contained in:
Philip Withnall 2023-11-02 17:49:31 +00:00
parent a0de4963e8
commit c37bf851e5

View File

@ -44,7 +44,7 @@ static void
wait_for_read (gboolean success,
gsize read)
{
g_assert (!got_read_done);
g_assert_false (got_read_done);
expected_read_success = success;
expected_read = read;
@ -76,7 +76,7 @@ static void
wait_for_write (gboolean success,
gsize written)
{
g_assert (!got_write_done);
g_assert_false (got_write_done);
expected_write_success = success;
expected_written = written;
@ -110,7 +110,7 @@ test_write_all_async_memory (void)
g_output_stream_write_all_async (ms, "0123456789", 10, 0, NULL, write_done, NULL);
wait_for_write (FALSE, 0);
g_assert (!memcmp (b, "012345678901234567890123", 24));
g_assert_cmpint (memcmp (b, "012345678901234567890123", 24), ==, 0);
g_object_unref (ms);
}
@ -126,16 +126,16 @@ test_read_all_async_memory (void)
g_input_stream_read_all_async (ms, buf, 10, 0, NULL, read_done, NULL);
wait_for_read (TRUE, 10);
g_assert (!memcmp (buf, "0123456789", 10));
g_assert_cmpint (memcmp (buf, "0123456789", 10), ==, 0);
g_input_stream_read_all_async (ms, buf, 10, 0, NULL, read_done, NULL);
wait_for_read (TRUE, 10);
g_assert (!memcmp (buf, "ABCDEFGHIJ", 10));
g_assert_cmpint (memcmp (buf, "ABCDEFGHIJ", 10), ==, 0);
/* partial read... */
g_input_stream_read_all_async (ms, buf, 10, 0, NULL, read_done, NULL);
wait_for_read (TRUE, 4);
g_assert (!memcmp (buf, "!@#$", 4));
g_assert_cmpint (memcmp (buf, "!@#$", 4), ==, 0);
/* EOF */
g_input_stream_read_all_async (ms, buf, 10, 0, NULL, read_done, NULL);
@ -180,7 +180,7 @@ test_read_write_all_async_pipe (void)
{
s = g_output_stream_write (out, wbuf, sizeof wbuf, NULL, &error);
g_assert_no_error (error);
g_assert (s > 0);
g_assert_cmpint (s, >, 0);
in_flight += s;
}
@ -189,7 +189,7 @@ test_read_write_all_async_pipe (void)
g_output_stream_write_all_async (out, "0123456789", 10, 0, cancellable, write_done, NULL);
while (g_main_context_iteration (NULL, FALSE))
;
g_assert (!got_write_done);
g_assert_false (got_write_done);
/* Cancel that to make sure it works */
g_cancellable_cancel (cancellable);
@ -200,7 +200,7 @@ test_read_write_all_async_pipe (void)
g_output_stream_write_all_async (out, "0123456789", 10, 0, NULL, write_done, NULL);
while (g_main_context_iteration (NULL, FALSE))
;
g_assert (!got_write_done);
g_assert_false (got_write_done);
/* Now drain as much as we originally put in the buffer to make it
* block -- this will unblock the writer.
@ -209,7 +209,7 @@ test_read_write_all_async_pipe (void)
{
s = g_input_stream_read (in, rbuf, MIN (sizeof wbuf, in_flight), NULL, &error);
g_assert_no_error (error);
g_assert (s > 0);
g_assert_cmpint (s, >, 0);
in_flight -= s;
}
@ -221,7 +221,7 @@ test_read_write_all_async_pipe (void)
/* The write is surely finished by now */
wait_for_write (TRUE, 10);
/* ...but the read will not yet be satisfied */
g_assert (!got_read_done);
g_assert_false (got_read_done);
/* Feed the read more than it asked for; this really should not block
* since the buffer is so small...