mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-28 10:06:53 +02:00
convert: Improve test coverage
Add a test that excercises the 'no conversion' code path. This uncovered that we don't treat errno properly in this path, and as a consequence, the returned error code is unreliable.
This commit is contained in:
parent
7d489acecc
commit
cbeecdc4ae
@ -685,11 +685,28 @@ test_filename_display (void)
|
|||||||
g_free (display);
|
g_free (display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_no_conv (void)
|
||||||
|
{
|
||||||
|
gchar *in = "";
|
||||||
|
gchar *out G_GNUC_UNUSED;
|
||||||
|
gsize bytes_read = 0;
|
||||||
|
gsize bytes_written = 0;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
out = g_convert (in, -1, "XXX", "UVZ",
|
||||||
|
&bytes_read, &bytes_written, &error);
|
||||||
|
|
||||||
|
/* error code is unreliable, since we mishandle errno there */
|
||||||
|
g_assert (error && error->domain == G_CONVERT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
|
g_test_add_func ("/conversion/no-conv", test_no_conv);
|
||||||
g_test_add_func ("/conversion/iconv-state", test_iconv_state);
|
g_test_add_func ("/conversion/iconv-state", test_iconv_state);
|
||||||
g_test_add_func ("/conversion/illegal-sequence", test_one_half);
|
g_test_add_func ("/conversion/illegal-sequence", test_one_half);
|
||||||
g_test_add_func ("/conversion/byte-order", test_byte_order);
|
g_test_add_func ("/conversion/byte-order", test_byte_order);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user