[glib/wip/resources] resources: Use g_assert[_no]_error in the test suite
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/resources] resources: Use g_assert[_no]_error in the test suite
- Date: Wed, 11 Jan 2012 13:26:27 +0000 (UTC)
commit a071abb1f563f5163c9b29a5df85ae78997d2084
Author: Christian Persch <chpe gnome org>
Date: Wed Jan 11 13:50:53 2012 +0100
resources: Use g_assert[_no]_error in the test suite
gio/tests/resources.c | 80 ++++++++++++++++++++++++------------------------
1 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/gio/tests/resources.c b/gio/tests/resources.c
index 0ac6a1d..9d84926 100644
--- a/gio/tests/resources.c
+++ b/gio/tests/resources.c
@@ -38,7 +38,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (!found);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
found = g_resource_get_info (resource,
@@ -46,7 +46,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == (G_RESOURCE_FLAGS_LOCALIZED | G_RESOURCE_FLAGS_COMPRESSED));
@@ -55,7 +55,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -64,7 +64,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -73,7 +73,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -82,7 +82,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_bytes_unref (data);
in = g_resource_open_stream (resource,
@@ -90,13 +90,13 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (in != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
success = g_input_stream_read_all (in, buffer, sizeof (buffer) - 1,
&size,
NULL, &error);
g_assert (success);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
buffer[size] = 0;
g_assert_cmpstr (buffer, ==, "test1\n");
@@ -108,7 +108,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
@@ -119,7 +119,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
@@ -130,7 +130,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test3\n");
g_bytes_unref (data);
@@ -140,7 +140,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (children == NULL);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
children = g_resource_enumerate_children (resource,
@@ -148,7 +148,7 @@ test_resource (GResource *resource)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (children != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (g_strv_length (children) == 2);
g_strfreev (children);
}
@@ -161,12 +161,12 @@ test_resource_file (void)
resource = g_resource_load ("not-there", &error);
g_assert (resource == NULL);
- g_assert (error != NULL);
+ g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
g_clear_error (&error);
resource = g_resource_load ("test.gresource", &error);
g_assert (resource != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
test_resource (resource);
g_resource_unref (resource);
@@ -189,7 +189,7 @@ test_resource_data (void)
data = g_bytes_new_take (content, content_size);
resource = g_resource_new_from_data (data, &error);
g_assert (resource != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
test_resource (resource);
@@ -211,13 +211,13 @@ test_resource_registred (void)
resource = g_resource_load ("test.gresource", &error);
g_assert (resource != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
found = g_resources_get_info ("/test1.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (!found);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
g_resources_register (resource);
@@ -226,7 +226,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == (G_RESOURCE_FLAGS_LOCALIZED | G_RESOURCE_FLAGS_COMPRESSED));
@@ -234,7 +234,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -242,7 +242,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -250,7 +250,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -258,20 +258,20 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_bytes_unref (data);
in = g_resources_open_stream ("/test1.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (in != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
success = g_input_stream_read_all (in, buffer, sizeof (buffer) - 1,
&size,
NULL, &error);
g_assert (success);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
buffer[size] = 0;
g_assert_cmpstr (buffer, ==, "test1\n");
@@ -283,7 +283,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
@@ -293,7 +293,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test2\n");
@@ -303,7 +303,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test3\n");
@@ -313,14 +313,14 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (children == NULL);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
children = g_resources_enumerate_children ("/a_prefix",
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (children != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (g_strv_length (children) == 2);
g_resources_unregister (resource);
@@ -329,7 +329,7 @@ test_resource_registred (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (!found);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
}
@@ -346,7 +346,7 @@ test_resource_automatic (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -354,7 +354,7 @@ test_resource_automatic (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
@@ -374,7 +374,7 @@ test_resource_manual (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -382,7 +382,7 @@ test_resource_manual (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
@@ -417,7 +417,7 @@ test_resource_module (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (!found);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
/* Load the module */
@@ -428,7 +428,7 @@ test_resource_module (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
g_assert (size == 6);
g_assert (flags == 0);
@@ -436,7 +436,7 @@ test_resource_module (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&error);
g_assert (data != NULL);
- g_assert (error == NULL);
+ g_assert_no_error (error);
size = g_bytes_get_size (data);
g_assert (size == 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
@@ -450,7 +450,7 @@ test_resource_module (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (found);
- g_assert (error == NULL);
+ g_assert_no_error (error);
/* Unref the data, should unload the module */
@@ -460,7 +460,7 @@ test_resource_module (void)
G_RESOURCE_LOOKUP_FLAGS_NONE,
&size, &flags, &error);
g_assert (!found);
- g_assert (error != NULL);
+ g_assert_error (error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND);
g_clear_error (&error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]