mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-31 22:23:39 +02:00
Add properties to GMemoryOutputStream
This helps bindings. Patch by Krzysztof Kosiński. See bug 605733.
This commit is contained in:
@@ -85,6 +85,42 @@ test_data_size (void)
|
||||
g_object_unref (mo);
|
||||
}
|
||||
|
||||
static void
|
||||
test_properties (void)
|
||||
{
|
||||
GOutputStream *mo;
|
||||
GDataOutputStream *o;
|
||||
int i;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_bug ("605733");
|
||||
|
||||
mo = (GOutputStream*) g_object_new (G_TYPE_MEMORY_OUTPUT_STREAM,
|
||||
"realloc-function", g_realloc,
|
||||
"destroy-function", g_free,
|
||||
NULL);
|
||||
o = g_data_output_stream_new (mo);
|
||||
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
g_data_output_stream_put_byte (o, 1, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
gsize data_size_fun = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (mo));
|
||||
gsize data_size_prop;
|
||||
g_object_get (mo, "data-size", &data_size_prop, NULL);
|
||||
g_assert_cmpint (data_size_fun, ==, data_size_prop);
|
||||
|
||||
gpointer data_fun = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (mo));
|
||||
gpointer data_prop;
|
||||
g_object_get (mo, "data", &data_prop, NULL);
|
||||
g_assert_cmphex (data_fun, ==, data_prop);
|
||||
|
||||
g_object_unref (o);
|
||||
g_object_unref (mo);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@@ -95,6 +131,7 @@ main (int argc,
|
||||
|
||||
g_test_add_func ("/memory-output-stream/truncate", test_truncate);
|
||||
g_test_add_func ("/memory-output-stream/get-data-size", test_data_size);
|
||||
g_test_add_func ("/memory-output-stream/properties", test_properties);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
Reference in New Issue
Block a user