2009-27-09 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / tests / dummyatk / useful_functions.c
1 #include <string.h>
2 #include <glib.h>
3 /*
4  * Functions and macros widely used in the tests.
5  */
6  
7 //same as strcmp() == 0 but works properly for NULL pointers
8 gboolean my_strcmp(const gchar* str1, const gchar* str2)
9 {
10     if(str1 == str2) return TRUE;
11     if(str1 == NULL || str2 == NULL) return FALSE;
12     
13     return strcmp(str1,str2) == 0;
14 }
15 //same as strlen but works properly for NULL pointer and returns gint instead of guint
16 gint my_strlen(const gchar* str)
17 {
18     if(str == NULL)return 0;
19     return (gint)strlen(str);
20 }
21 //same as strncmp() == 0 but works properly for NULL pointers
22 gboolean my_strncmp(const gchar* str1, const gchar* str2, gint n)
23 {
24     if(n <= 0)return TRUE;
25     if(str1 == str2)return TRUE;
26     if(str1 == NULL || str2 == NULL)return FALSE;
27
28     return strncmp(str1, str2, n) == 0;
29 }