g_buffered_input_stream_set_buffer_size (G_BUFFERED_INPUT_STREAM (in), 2);
size = g_buffered_input_stream_get_buffer_size (G_BUFFERED_INPUT_STREAM (in));
g_assert_cmpint (size, ==, bufsize);
+ g_object_get (in, "buffer-size", &size, NULL);
+ g_assert_cmpint (size, ==, bufsize);
g_object_unref (in);
GInputStream *mem, *cstream;
GOutputStream *mem_out, *cstream_out;
GConverter *expander;
+ GConverter *converter;
GError *error;
int i;
NULL);
cstream = g_converter_input_stream_new (mem, expander);
g_assert (g_converter_input_stream_get_converter (G_CONVERTER_INPUT_STREAM (cstream)) == expander);
+ g_object_get (cstream, "converter", &converter, NULL);
+ g_assert (converter == expander);
+ g_object_unref (converter);
g_object_unref (mem);
total_read = 0;
#define MAX_BYTES 0x10000
static void
+test_basic (void)
+{
+ GInputStream *stream;
+ GInputStream *base_stream;
+ gint val;
+
+ base_stream = g_memory_input_stream_new ();
+ stream = G_INPUT_STREAM (g_data_input_stream_new (base_stream));
+
+ g_object_get (stream, "byte-order", &val, NULL);
+ g_assert_cmpint (val, ==, G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
+ g_object_set (stream, "byte-order", G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN, NULL);
+ g_assert_cmpint (g_data_input_stream_get_byte_order (G_DATA_INPUT_STREAM (stream)), ==, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
+
+ g_object_get (stream, "newline-type", &val, NULL);
+ g_assert_cmpint (val, ==, G_DATA_STREAM_NEWLINE_TYPE_LF);
+ g_object_set (stream, "newline-type", G_DATA_STREAM_NEWLINE_TYPE_CR_LF, NULL);
+ g_assert_cmpint (g_data_input_stream_get_newline_type (G_DATA_INPUT_STREAM (stream)), ==, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
+
+ g_object_unref (stream);
+ g_object_unref (base_stream);
+}
+
+static void
test_seek_to_start (GInputStream *stream)
{
GError *error = NULL;
test_read_lines (G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
}
+static void
+test_read_lines_any (void)
+{
+ test_read_lines (G_DATA_STREAM_NEWLINE_TYPE_ANY);
+}
static void
test_read_until (void)
g_type_init ();
g_test_init (&argc, &argv, NULL);
+ g_test_add_func ("/data-input-stream/basic", test_basic);
g_test_add_func ("/data-input-stream/read-lines-LF", test_read_lines_LF);
g_test_add_func ("/data-input-stream/read-lines-CR", test_read_lines_CR);
g_test_add_func ("/data-input-stream/read-lines-CR-LF", test_read_lines_CR_LF);
+ g_test_add_func ("/data-input-stream/read-lines-any", test_read_lines_any);
g_test_add_func ("/data-input-stream/read-until", test_read_until);
g_test_add_func ("/data-input-stream/read-int", test_read_int);
#define MAX_BYTES_BINARY 0x100
static void
+test_basic (void)
+{
+ GOutputStream *stream;
+ GOutputStream *base_stream;
+ gpointer data;
+ gint val;
+
+ data = g_malloc0 (MAX_LINES_BUFF);
+
+ /* initialize objects */
+ base_stream = g_memory_output_stream_new (data, MAX_LINES_BUFF, NULL, NULL);
+ stream = G_OUTPUT_STREAM (g_data_output_stream_new (base_stream));
+
+ g_object_get (stream, "byte-order", &val, NULL);
+ g_assert_cmpint (val, ==, G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
+ g_object_set (stream, "byte-order", G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN, NULL);
+ g_assert_cmpint (g_data_output_stream_get_byte_order (G_DATA_OUTPUT_STREAM (stream)), ==, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
+
+ g_object_unref (stream);
+ g_object_unref (base_stream);
+}
+
+static void
test_read_lines (GDataStreamNewlineType newline_type)
{
GOutputStream *stream;
g_type_init ();
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/data-input-stream/read-lines-LF", test_read_lines_LF);
- g_test_add_func ("/data-input-stream/read-lines-CR", test_read_lines_CR);
- g_test_add_func ("/data-input-stream/read-lines-CR-LF", test_read_lines_CR_LF);
- g_test_add_func ("/data-input-stream/read-int", test_read_int);
+ g_test_add_func ("/data-output-stream/basic", test_basic);
+ g_test_add_func ("/data-output-stream/write-lines-LF", test_read_lines_LF);
+ g_test_add_func ("/data-output-stream/write-lines-CR", test_read_lines_CR);
+ g_test_add_func ("/data-output-stream/write-lines-CR-LF", test_read_lines_CR_LF);
+ g_test_add_func ("/data-output-stream/write-int", test_read_int);
return g_test_run();
}