Make all aux functions static.

* testglib.c:
        Make all aux functions static.

        * tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
        New tests dirname-test and type-test, from testglib.
This commit is contained in:
Jeff Garzik 1999-01-09 20:10:45 +00:00
parent 2a6789be13
commit 5eeca0d62d
14 changed files with 236 additions and 21 deletions

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -1,3 +1,11 @@
Sat Jan 9 15:08:44 1999 Jeff Garzik <jgarzik@pobox.com>
* testglib.c:
Make all aux functions static.
* tests/Makefile.am, tests/dirname-test.c, tests/type-test.c:
New tests dirname-test and type-test, from testglib.
Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com> Sat Jan 9 13:53:00 1999 Jeff Garzik <jgarzik@pobox.com>
* configure.in: * configure.in:

View File

@ -185,7 +185,7 @@ g_node_test (void)
g_print ("ok\n"); g_print ("ok\n");
} }
gboolean static gboolean
my_hash_callback_remove (gpointer key, my_hash_callback_remove (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -198,7 +198,7 @@ my_hash_callback_remove (gpointer key,
return FALSE; return FALSE;
} }
void static void
my_hash_callback_remove_test (gpointer key, my_hash_callback_remove_test (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -209,7 +209,7 @@ my_hash_callback_remove_test (gpointer key,
g_print ("bad!\n"); g_print ("bad!\n");
} }
void static void
my_hash_callback (gpointer key, my_hash_callback (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -218,20 +218,20 @@ my_hash_callback (gpointer key,
*d = 1; *d = 1;
} }
guint static guint
my_hash (gconstpointer key) my_hash (gconstpointer key)
{ {
return (guint) *((const gint*) key); return (guint) *((const gint*) key);
} }
gint static gint
my_hash_compare (gconstpointer a, my_hash_compare (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
return *((const gint*) a) == *((const gint*) b); return *((const gint*) a) == *((const gint*) b);
} }
gint static gint
my_list_compare_one (gconstpointer a, gconstpointer b) my_list_compare_one (gconstpointer a, gconstpointer b)
{ {
gint one = *((const gint*)a); gint one = *((const gint*)a);
@ -239,7 +239,7 @@ my_list_compare_one (gconstpointer a, gconstpointer b)
return one-two; return one-two;
} }
gint static gint
my_list_compare_two (gconstpointer a, gconstpointer b) my_list_compare_two (gconstpointer a, gconstpointer b)
{ {
gint one = *((const gint*)a); gint one = *((const gint*)a);
@ -247,14 +247,14 @@ my_list_compare_two (gconstpointer a, gconstpointer b)
return two-one; return two-one;
} }
/* void /* static void
my_list_print (gpointer a, gpointer b) my_list_print (gpointer a, gpointer b)
{ {
gint three = *((gint*)a); gint three = *((gint*)a);
g_print("%d", three); g_print("%d", three);
}; */ }; */
gint static gint
my_compare (gconstpointer a, my_compare (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
@ -264,7 +264,7 @@ my_compare (gconstpointer a,
return *cha - *chb; return *cha - *chb;
} }
gint static gint
my_traverse (gpointer key, my_traverse (gpointer key,
gpointer value, gpointer value,
gpointer data) gpointer data)

View File

@ -31,3 +31,5 @@ slist-test
string-test string-test
array-test array-test
tree-test tree-test
dirname-test
type-test

View File

@ -4,18 +4,21 @@ INCLUDES = -I$(top_srcdir)
TESTS = \ TESTS = \
alloca-test \ alloca-test \
array-test \ array-test \
dirname-test \
hash-test \ hash-test \
list-test \ list-test \
node-test \ node-test \
relation-test \ relation-test \
slist-test \ slist-test \
string-test \ string-test \
tree-test tree-test \
type-test
noinst_PROGRAMS = $(TESTS) noinst_PROGRAMS = $(TESTS)
alloca_test_LDADD = $(top_builddir)/libglib.la alloca_test_LDADD = $(top_builddir)/libglib.la
array_test_LDADD = $(top_builddir)/libglib.la array_test_LDADD = $(top_builddir)/libglib.la
dirname_test_LDADD = $(top_builddir)/libglib.la
hash_test_LDADD = $(top_builddir)/libglib.la hash_test_LDADD = $(top_builddir)/libglib.la
list_test_LDADD = $(top_builddir)/libglib.la list_test_LDADD = $(top_builddir)/libglib.la
node_test_LDADD = $(top_builddir)/libglib.la node_test_LDADD = $(top_builddir)/libglib.la
@ -23,4 +26,5 @@ relation_test_LDADD = $(top_builddir)/libglib.la
slist_test_LDADD = $(top_builddir)/libglib.la slist_test_LDADD = $(top_builddir)/libglib.la
string_test_LDADD = $(top_builddir)/libglib.la string_test_LDADD = $(top_builddir)/libglib.la
tree_test_LDADD = $(top_builddir)/libglib.la tree_test_LDADD = $(top_builddir)/libglib.la
type_test_LDADD = $(top_builddir)/libglib.la

92
tests/dirname-test.c Normal file
View File

@ -0,0 +1,92 @@
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#undef G_LOG_DOMAIN
#include <stdio.h>
#include <string.h>
#include "glib.h"
int array[10000];
gboolean failed = FALSE;
#define TEST(m,cond) G_STMT_START { failed = !(cond); \
if (failed) \
{ if (!m) \
g_print ("\n(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \
else \
g_print ("\n(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), (gchar*)m); \
} \
else \
g_print ("."); fflush (stdout); \
} G_STMT_END
#define C2P(c) ((gpointer) ((long) (c)))
#define P2C(p) ((gchar) ((long) (p)))
#define GLIB_TEST_STRING "el dorado "
#define GLIB_TEST_STRING_5 "el do"
int
main (int argc,
char *argv[])
{
gint i;
struct {
gchar *filename;
gchar *dirname;
} dirname_checks[] = {
#ifndef NATIVE_WIN32
{ "/", "/" },
{ "////", "/" },
{ ".////", "." },
{ ".", "." },
{ "..", "." },
{ "../", ".." },
{ "..////", ".." },
{ "", "." },
{ "a/b", "a" },
{ "a/b/", "a/b" },
{ "c///", "c" },
#else
{ "\\", "\\" },
{ ".\\\\\\\\", "." },
{ ".", "." },
{ "..", "." },
{ "..\\", ".." },
{ "..\\\\\\\\", ".." },
{ "", "." },
{ "a\\b", "a" },
{ "a\\b\\", "a\\b" },
{ "c\\\\\\", "c" },
#endif
};
guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
for (i = 0; i < n_dirname_checks; i++)
{
gchar *dirname;
dirname = g_dirname (dirname_checks[i].filename);
g_assert (strcmp (dirname, dirname_checks[i].dirname) == 0);
g_free (dirname);
}
return 0;
}

View File

@ -185,7 +185,7 @@ g_node_test (void)
g_print ("ok\n"); g_print ("ok\n");
} }
gboolean static gboolean
my_hash_callback_remove (gpointer key, my_hash_callback_remove (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -198,7 +198,7 @@ my_hash_callback_remove (gpointer key,
return FALSE; return FALSE;
} }
void static void
my_hash_callback_remove_test (gpointer key, my_hash_callback_remove_test (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -209,7 +209,7 @@ my_hash_callback_remove_test (gpointer key,
g_print ("bad!\n"); g_print ("bad!\n");
} }
void static void
my_hash_callback (gpointer key, my_hash_callback (gpointer key,
gpointer value, gpointer value,
gpointer user_data) gpointer user_data)
@ -218,20 +218,20 @@ my_hash_callback (gpointer key,
*d = 1; *d = 1;
} }
guint static guint
my_hash (gconstpointer key) my_hash (gconstpointer key)
{ {
return (guint) *((const gint*) key); return (guint) *((const gint*) key);
} }
gint static gint
my_hash_compare (gconstpointer a, my_hash_compare (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
return *((const gint*) a) == *((const gint*) b); return *((const gint*) a) == *((const gint*) b);
} }
gint static gint
my_list_compare_one (gconstpointer a, gconstpointer b) my_list_compare_one (gconstpointer a, gconstpointer b)
{ {
gint one = *((const gint*)a); gint one = *((const gint*)a);
@ -239,7 +239,7 @@ my_list_compare_one (gconstpointer a, gconstpointer b)
return one-two; return one-two;
} }
gint static gint
my_list_compare_two (gconstpointer a, gconstpointer b) my_list_compare_two (gconstpointer a, gconstpointer b)
{ {
gint one = *((const gint*)a); gint one = *((const gint*)a);
@ -247,14 +247,14 @@ my_list_compare_two (gconstpointer a, gconstpointer b)
return two-one; return two-one;
} }
/* void /* static void
my_list_print (gpointer a, gpointer b) my_list_print (gpointer a, gpointer b)
{ {
gint three = *((gint*)a); gint three = *((gint*)a);
g_print("%d", three); g_print("%d", three);
}; */ }; */
gint static gint
my_compare (gconstpointer a, my_compare (gconstpointer a,
gconstpointer b) gconstpointer b)
{ {
@ -264,7 +264,7 @@ my_compare (gconstpointer a,
return *cha - *chb; return *cha - *chb;
} }
gint static gint
my_traverse (gpointer key, my_traverse (gpointer key,
gpointer value, gpointer value,
gpointer data) gpointer data)

53
tests/type-test.c Normal file
View File

@ -0,0 +1,53 @@
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#undef G_LOG_DOMAIN
#include <stdio.h>
#include <string.h>
#include "glib.h"
int
main (int argc,
char *argv[])
{
guint16 gu16t1 = 0x44afU, gu16t2 = 0xaf44U;
guint32 gu32t1 = 0x02a7f109U, gu32t2 = 0x09f1a702U;
#ifdef G_HAVE_GINT64
guint64 gu64t1 = G_GINT64_CONSTANT(0x1d636b02300a7aa7U),
gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU);
#endif
/* type sizes */
g_assert (sizeof (gint8) == 1);
g_assert (sizeof (gint16) == 2);
g_assert (sizeof (gint32) == 4);
#ifdef G_HAVE_GINT64
g_assert (sizeof (gint64) == 8);
#endif /* G_HAVE_GINT64 */
g_assert (GUINT16_SWAP_LE_BE (gu16t1) == gu16t2);
g_assert (GUINT32_SWAP_LE_BE (gu32t1) == gu32t2);
#ifdef G_HAVE_GINT64
g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2);
#endif
return 0;
}