mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-04 00:13:40 +02:00
Avoid non-ANSI pointer comparison. (#54344, Morten Welinder)
Tue Nov 26 09:51:43 2002 Owen Taylor <otaylor@redhat.com> * glib/gstrfuncs.c (g_strchomp): Avoid non-ANSI pointer comparison. (#54344, Morten Welinder) * tests/strfunc-test.c (main): Add tests for strchomp().
This commit is contained in:
@@ -92,6 +92,20 @@ str_check (gchar *str,
|
||||
return ok;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
strchomp_check (gchar *str,
|
||||
gchar *expected)
|
||||
{
|
||||
gchar *tmp = strdup (str);
|
||||
gboolean ok;
|
||||
|
||||
g_strchomp (tmp);
|
||||
ok = (strcmp (tmp, expected) == 0);
|
||||
g_free (tmp);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
#define FOR_ALL_CTYPE(macro) \
|
||||
macro(isalnum) \
|
||||
macro(isalpha) \
|
||||
@@ -331,6 +345,15 @@ main (int argc,
|
||||
|
||||
#undef TEST_DIGIT
|
||||
|
||||
/* Tests for strchomp () */
|
||||
TEST (NULL, strchomp_check ("", ""));
|
||||
TEST (NULL, strchomp_check (" ", ""));
|
||||
TEST (NULL, strchomp_check (" \t\r\n", ""));
|
||||
TEST (NULL, strchomp_check ("a ", "a"));
|
||||
TEST (NULL, strchomp_check ("a ", "a"));
|
||||
TEST (NULL, strchomp_check ("a a", "a a"));
|
||||
TEST (NULL, strchomp_check ("a a ", "a a"));
|
||||
|
||||
/* Tests for g_build_path, g_build_filename */
|
||||
|
||||
TEST (NULL, str_check (g_build_path ("", NULL), ""));
|
||||
|
Reference in New Issue
Block a user