Commit Graph

24 Commits

Author SHA1 Message Date
Simon McVittie
32b0dd24e3 Add a SPDX LicenseRef for the license historically used for tests
Some of GLib's unit tests are under an apparently GLib-specific
permissive license, vaguely similar to the BSD/MIT family but with the
GPL's lack-of-warranty wording. This is not on SPDX's list of
well-known licenses, so we need to use a custom license name prefixed
with LicenseRef if we want to represent this in SPDX/REUSE syntax.

Most of the newer tests seem to be licensed under LGPL-2.1-or-later
instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:34:19 +00:00
James Westman
f6ddce4b16 g_output_stream_write_all: Allow NULL empty buffer 2021-09-21 10:40:14 +00:00
Philip Withnall
7e9585177d tests: Drop use of g_test_bug_base()
Include the base URI in the `g_test_bug()` calls instead. This resolves
inconsistencies between the old bug base (bugzilla.gnome.org) and the
new bug base (gitlab.gnome.org). It also has the advantage that the URI
passed to `g_test_bug()` is now clickable in the code editor, rather
than being split across two locations.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/275#note_303175

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 22:16:27 +01:00
Sebastian Dröge
708aa8f4ee Add some tests for g_output_stream_writev() and its async variant 2019-01-24 16:25:56 +02:00
Matthias Clasen
5ccdf2b86a Expand the truncate tests
Check that the data is expanded with zeros.
2013-12-15 21:07:12 -05:00
Ross Lagerwall
3b9ad6e6ef gio: Update GMemoryOutputStream length after truncate
For GMemoryOutputStream, update valid_len when truncating so that
g_memory_output_stream_get_data_size () returns the correct result.

https://bugzilla.gnome.org/show_bug.cgi?id=720080
2013-12-15 11:54:39 -05:00
Chun-wei Fan
b9322bf9ab gio/tests/memory-output-stream.c: Avoid an uninitialized variable
Be a little bit more careful in regards to initializing a primitive type
variable before passing it by reference, as it could have random stuff
in the variable's address depending on the CRT, such as MSVCR110.DLL,
causing random, invalid stuff being written in that address.

This will fix this test when built with Visual Studio 2012.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-27 08:01:47 +08:00
Ryan Lortie
1d1c17d9ee GMemoryOutputStream: improve seek tests
Improve test coverage for testing seeking on fixed vs. resizable
GMemoryOutputStream.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:32:13 -04:00
Ryan Lortie
fdc5cd8d9f Change semantics of seek on memory output stream
It is our intention that memory output streams should operate in two
distinct modes, depending on if a realloc function was provided or not.

In the case that we have a realloc function (resizable mode), we want
the stream to behave as if it were a file that started out empty.  In
the case that we don't have a realloc function (fixed-sized mode), we
want the stream to behave as a block device would.

To this end, we introduce two changes in functionality:

 - seeking to SEEK_END on a resizable stream will now seek to the end of
   the valid data region, not to the end of the allocated memory (which
   is really just an implementation detail)

 - seeks past the end of the allocated memory size are now permitted,
   but only on resizable streams.  The next write will grow the buffer
   (inserting zeros between).

Some tweaks to testcases were required in order not to break the build,
which indicates that this is an API break, but it seems unlikely that
anyone will be effected by these changes 'in the real world'.

Updates to documentation and further testcases are in following commits.

Based on a patch from Maciej Piechotka <uzytkownik2@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:31:27 -04:00
Matthias Clasen
fed8ae38c3 Improve test coverage a bit 2013-06-01 18:51:25 -04:00
Colin Walters
ed5c17e11f GMemoryOutputStream: Add new _resizable() constructor usable from bindings
Really, the memory output stream API is too warped around the model
where it's a fixed size buffer that you've already allocated.  Even in
C, I find myself always wanting to use it to just accumulate data into
an arbitrary-sized buffer it allocates.

Unfortunately, it's also not usable from bindings because it's not
common to bind g_free() and g_realloc(), but if you just pass NULL, you
get the default of a fixed size, which is useless as per above.

I am going to use this from a gjs test case, and the GSubprocess test
cases also will use it.

https://bugzilla.gnome.org/show_bug.cgi?id=688931
2012-11-27 20:45:21 -05:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Dan Winship
800d6ff111 gio: add GBytes-based input/output stream methods
Using a caller-supplied buffer for g_input_stream_read() doesn't
translate well to the semantics of many other languages, and using a
non-refcounted buffer for read_async() and write_async() makes it
impossible to manage the memory correctly currently in
garbage-collected languages.

Fix both of these issues by adding a new set of methods that work with
GBytes objects rather than plain buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=671139
2012-05-24 17:48:13 -04:00
Colin Walters
44d4990442 GMemoryOutputStream: Add API to return data as a GBytes
Matches the corresponding additions to GMemoryInputStream.

https://bugzilla.gnome.org/show_bug.cgi?id=672102
2012-05-21 13:45:15 -04:00
Antoine Jacoutot
ce0f7cafa1 Fix build with gcc-2.*.
https://bugzilla.gnome.org/show_bug.cgi?id=650884
2011-05-23 13:05:49 -04:00
Matthias Clasen
9794a648a9 Improve coverage of memory stream tests 2010-07-30 19:51:21 -04:00
Benjamin Otte
dd1d1b3510 tests: Use GPOINTER_TO_SIZE() instead of just casting to guint
a) gcc doesn't like this ("Cast to pointer of different size)
b) It compares only half of the pointer
2010-07-22 21:56:20 +02:00
Juan A. Suarez Romero
992e07c8b2 Fix warnings
Do explicit casts to avoid warnings.
2010-06-09 10:32:12 +02:00
Matthias Clasen
759fbac7b7 Add properties to GMemoryOutputStream
This helps bindings. Patch by Krzysztof Kosiński. See bug 605733.
2010-01-06 17:37:11 -05:00
Matthias Clasen
5694ab7642 Revert "Move gio tests from gio/tests/ to tests/gio/"
This reverts commit 2262d76b33.

Move GIO tests back to where they belong.
2009-07-05 22:49:24 -04:00
Benjamin Otte
2262d76b33 Move gio tests from gio/tests/ to tests/gio/
This avoids getting tests built every time when working on libgio and
running make in the gio/ directory.
2009-07-01 19:03:19 +02:00
Alexander Larsson
b89e432e8d Bug 540461 – g_memory_output_stream_get_data_size() doesn't behave as
2009-02-26  Alexander Larsson  <alexl@redhat.com>

	Bug 540461 – g_memory_output_stream_get_data_size() doesn't behave as document
        * gmemoryoutputstream.c:
	Track actual valid size, even if we later seek back.

        * tests/memory-output-stream.c:
	Add testcase



svn path=/trunk/; revision=7916
2009-02-26 15:41:29 +00:00
Dan Winship
29ddd48ff2 Use g_assert_error() and g_assert_no_error()
* tests/data-input-stream.c:
	* tests/data-output-stream.c:
	* tests/live-g-file.c:
	* tests/memory-input-stream.c:
	* tests/memory-output-stream.c: Use g_assert_error() and
	g_assert_no_error()

svn path=/trunk/; revision=7556
2008-09-27 01:43:43 +00:00
Matthias Clasen
e3313b2651 Add some tests for GMemoryOutputStream.
2008-06-29  Matthias Clasen  <mclasen@redhat.com>

        * tests/Makefile.am:
        * tests/memory-output-stream.c: Add some tests for
        GMemoryOutputStream.

2008-06-29  Matthias Clasen  <mclasen@redhat.com>

        Bug 540423 – unrecoverable error after g_seekable_truncate(seekable,
        0, ...)

        * gmemoryoutputstream.c (array_resize): Handle truncation to
        zero correctly. Reported by Akira Tagoh



svn path=/trunk/; revision=7106
2008-06-30 03:47:27 +00:00