diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-string.c | 15 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-string.h | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-string.c | 15 | ||||
-rw-r--r-- | libnautilus-private/nautilus-string.h | 2 |
5 files changed, 41 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2000-08-17 Ramiro Estrugo <ramiro@eazel.com> + + * libnautilus-extensions/nautilus-string.c: + (nautilus_str_is_equal), (nautilus_self_check_string): + * libnautilus-extensions/nautilus-string.h: + New function and tests. + 2000-08-17 John Sullivan <sullivan@eazel.com> Finished task 1991 (Need "Create Link" menu item) and did diff --git a/libnautilus-extensions/nautilus-string.c b/libnautilus-extensions/nautilus-string.c index 8dadec8b9..f740190a2 100644 --- a/libnautilus-extensions/nautilus-string.c +++ b/libnautilus-extensions/nautilus-string.c @@ -63,6 +63,12 @@ nautilus_str_is_empty (const char *string_or_null) return nautilus_strcmp (string_or_null, NULL) == 0; } +gboolean +nautilus_str_is_equal (const char *string_a, const char *string_b) +{ + return (nautilus_strcmp (string_a, string_b) == 0); +} + int nautilus_str_compare (gconstpointer string_a, gconstpointer string_b) { @@ -718,6 +724,15 @@ nautilus_self_check_string (void) TEST_INTEGER_CONVERSION_FUNCTIONS ("21474836470", FALSE, 9999) TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999) TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999) + + /* nautilus_str_is_equal */ + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, NULL), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", NULL), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "foo"), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "bar"), FALSE); } #endif /* !NAUTILUS_OMIT_SELF_CHECK */ diff --git a/libnautilus-extensions/nautilus-string.h b/libnautilus-extensions/nautilus-string.h index 09d6daccd..584a0f950 100644 --- a/libnautilus-extensions/nautilus-string.h +++ b/libnautilus-extensions/nautilus-string.h @@ -54,6 +54,8 @@ int nautilus_istr_compare (gconstpointer string_a, /* Other basic string operations. */ gboolean nautilus_str_is_empty (const char *string_or_null); +gboolean nautilus_str_is_equal (const char *string_a, + const char *string_b); gboolean nautilus_str_has_prefix (const char *target, const char *prefix); char * nautilus_str_get_prefix (const char *source, diff --git a/libnautilus-private/nautilus-string.c b/libnautilus-private/nautilus-string.c index 8dadec8b9..f740190a2 100644 --- a/libnautilus-private/nautilus-string.c +++ b/libnautilus-private/nautilus-string.c @@ -63,6 +63,12 @@ nautilus_str_is_empty (const char *string_or_null) return nautilus_strcmp (string_or_null, NULL) == 0; } +gboolean +nautilus_str_is_equal (const char *string_a, const char *string_b) +{ + return (nautilus_strcmp (string_a, string_b) == 0); +} + int nautilus_str_compare (gconstpointer string_a, gconstpointer string_b) { @@ -718,6 +724,15 @@ nautilus_self_check_string (void) TEST_INTEGER_CONVERSION_FUNCTIONS ("21474836470", FALSE, 9999) TEST_INTEGER_CONVERSION_FUNCTIONS ("+21474836470", FALSE, 9999) TEST_INTEGER_CONVERSION_FUNCTIONS ("-21474836480", FALSE, 9999) + + /* nautilus_str_is_equal */ + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, NULL), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal (NULL, ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", NULL), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("", ""), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "foo"), TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_str_is_equal ("foo", "bar"), FALSE); } #endif /* !NAUTILUS_OMIT_SELF_CHECK */ diff --git a/libnautilus-private/nautilus-string.h b/libnautilus-private/nautilus-string.h index 09d6daccd..584a0f950 100644 --- a/libnautilus-private/nautilus-string.h +++ b/libnautilus-private/nautilus-string.h @@ -54,6 +54,8 @@ int nautilus_istr_compare (gconstpointer string_a, /* Other basic string operations. */ gboolean nautilus_str_is_empty (const char *string_or_null); +gboolean nautilus_str_is_equal (const char *string_a, + const char *string_b); gboolean nautilus_str_has_prefix (const char *target, const char *prefix); char * nautilus_str_get_prefix (const char *source, |