summaryrefslogtreecommitdiff
path: root/testglib.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-07-14 07:39:07 +0000
committerTim Janik <timj@src.gnome.org>1998-07-14 07:39:07 +0000
commitacc1c38efe2decbd924cf9f4844d6fb3d86fcc4b (patch)
tree1eddb8462a8f5a28d07502d0416670fe68a89781 /testglib.c
parent478632418e0f99e1f440368cb499a0a1cc7ec2e9 (diff)
downloadglib-acc1c38efe2decbd924cf9f4844d6fb3d86fcc4b.tar.gz
glib-acc1c38efe2decbd924cf9f4844d6fb3d86fcc4b.tar.bz2
glib-acc1c38efe2decbd924cf9f4844d6fb3d86fcc4b.zip
new fuction g_dirname() which returns a newlly allocated string.
Tue Jul 14 09:05:18 1998 Tim Janik <timj@gtk.org> * glib.h: * gutils.c: new fuction g_dirname() which returns a newlly allocated string.
Diffstat (limited to 'testglib.c')
-rw-r--r--testglib.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/testglib.c b/testglib.c
index 818e49d0e..d89e76386 100644
--- a/testglib.c
+++ b/testglib.c
@@ -112,11 +112,48 @@ main (int argc,
GRelation *relation;
GTuples *tuples;
gint data [1024];
+ struct {
+ gchar *filename;
+ gchar *dirname;
+ } dirname_checks[] = {
+ { "/", "/" },
+ { "////", "/" },
+ { ".////", "." },
+ { ".", "." },
+ { "..", "." },
+ { "../", ".." },
+ { "..////", ".." },
+ { "", "." },
+ { "a/b", "a" },
+ { "a/b/", "a/b" },
+ { "c///", "c" },
+ };
+ guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
+
g_print ("checking size of gint8...%ld (should be 1)\n", (glong)sizeof (gint8));
g_print ("checking size of gint16...%ld (should be 2)\n", (glong)sizeof (gint16));
g_print ("checking size of gint32...%ld (should be 4)\n", (glong)sizeof (gint32));
+ g_print ("checking g_dirname()...");
+ for (i = 0; i < n_dirname_checks; i++)
+ {
+ gchar *dirname;
+
+ dirname = g_dirname (dirname_checks[i].filename);
+ if (strcmp (dirname, dirname_checks[i].dirname) != 0)
+ {
+ g_print ("failed for \"%s\"==\"%s\" (returned: \"%s\")\n",
+ dirname_checks[i].filename,
+ dirname_checks[i].dirname,
+ dirname);
+ n_dirname_checks = 0;
+ }
+ g_free (dirname);
+ }
+ if (n_dirname_checks)
+ g_print ("ok\n");
+
g_print ("checking doubly linked lists...");
list = NULL;