Add tests.

2006-06-16  Matthias Clasen  <mclasen@redhat.com>

	* tests/file-test.c (test_mkstemp): Add tests.

	* glib/gfileutils.c (g_mkstemp): Allow the XXXXXX to occur
	inside the template, not just at the end.
This commit is contained in:
Matthias Clasen
2006-06-16 15:12:32 +00:00
committed by Matthias Clasen
parent dd106106dc
commit 6cc8a27894
4 changed files with 50 additions and 30 deletions

View File

@@ -60,7 +60,13 @@ test_mkstemp (void)
strcpy (template, "foobar");
fd = g_mkstemp (template);
if (fd != -1)
g_warning ("g_mkstemp works even if template doesn't end in XXXXXX");
g_warning ("g_mkstemp works even if template doesn't contain XXXXXX");
close (fd);
strcpy (template, "foobarXXX");
fd = g_mkstemp (template);
if (fd != -1)
g_warning ("g_mkstemp works even if template contains less than six X");
close (fd);
strcpy (template, "fooXXXXXX");
@@ -80,6 +86,13 @@ test_mkstemp (void)
close (fd);
remove (template);
strcpy (template, "fooXXXXXX.pdf");
fd = g_mkstemp (template);
g_assert (fd != -1 && "g_mkstemp didn't work for template fooXXXXXX.pdf");
close (fd);
remove (template);
}
static void