[glib: 1/2] Move unit test on g_basename() function to glib/tests/fileutils.c
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] Move unit test on g_basename() function to glib/tests/fileutils.c
- Date: Mon, 21 Mar 2022 12:15:02 +0000 (UTC)
commit 7f7b5ba0937d70990c5b4bb6c0d70f099a4d448e
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date: Thu Mar 17 18:10:09 2022 +0100
Move unit test on g_basename() function to glib/tests/fileutils.c
g_basename() function is defined in glib/gfileutils.c which is tested
by glib/tests/fileutils.c test set. Until now, g_basename() test was
in glib/test/utils.c. This patch move the unit test to the proper file.
glib/tests/fileutils.c | 17 ++++++++++++++++-
glib/tests/utils.c | 12 ------------
2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c
index ae25578f9..e0ade532d 100644
--- a/glib/tests/fileutils.c
+++ b/glib/tests/fileutils.c
@@ -1059,7 +1059,8 @@ test_file_errors (void)
static void
test_basename (void)
{
- gchar *b;
+ const gchar *path = "/path/to/a/file/deep/down.sh";
+ const gchar *b;
if (g_test_undefined ())
{
@@ -1067,7 +1068,20 @@ test_basename (void)
"*assertion*!= NULL*");
g_assert_null (g_basename (NULL));
g_test_assert_expected_messages ();
+ }
+
+ b = g_basename (path);
+ g_assert_cmpstr (b, ==, "down.sh");
+}
+
+static void
+test_get_basename (void)
+{
+ gchar *b;
+
+ if (g_test_undefined ())
+ {
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*assertion*!= NULL*");
g_assert_null (g_path_get_basename (NULL));
@@ -2434,6 +2448,7 @@ main (int argc,
g_test_add_func ("/fileutils/format-size-for-display", test_format_size_for_display);
g_test_add_func ("/fileutils/errors", test_file_errors);
g_test_add_func ("/fileutils/basename", test_basename);
+ g_test_add_func ("/fileutils/get-basename", test_get_basename);
g_test_add_func ("/fileutils/dirname", test_dirname);
g_test_add_func ("/fileutils/dir-make-tmp", test_dir_make_tmp);
g_test_add_func ("/fileutils/file-open-tmp", test_file_open_tmp);
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index 0b4782fcf..11fed555a 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -593,17 +593,6 @@ test_console_charset (void)
#endif
}
-static void
-test_basename (void)
-{
- const gchar *path = "/path/to/a/file/deep/down.sh";
- const gchar *b;
-
- b = g_basename (path);
-
- g_assert_cmpstr (b, ==, "down.sh");
-}
-
extern const gchar *glib_pgettext (const gchar *msgidctxt, gsize msgidoffset);
static void
@@ -1162,7 +1151,6 @@ main (int argc,
g_test_add_func ("/utils/codeset", test_codeset);
g_test_add_func ("/utils/codeset2", test_codeset2);
g_test_add_func ("/utils/console-charset", test_console_charset);
- g_test_add_func ("/utils/basename", test_basename);
g_test_add_func ("/utils/gettext", test_gettext);
g_test_add_func ("/utils/username", test_username);
g_test_add_func ("/utils/realname", test_realname);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]