| 2961 | } |
| 2962 | |
| 2963 | CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) |
| 2964 | { |
| 2965 | if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) |
| 2966 | { |
| 2967 | return false; |
| 2968 | } |
| 2969 | |
| 2970 | /* check if type is valid */ |
| 2971 | switch (a->type & 0xFF) |
| 2972 | { |
| 2973 | case cJSON_False: |
| 2974 | case cJSON_True: |
| 2975 | case cJSON_NULL: |
| 2976 | case cJSON_Number: |
| 2977 | case cJSON_String: |
| 2978 | case cJSON_Raw: |
| 2979 | case cJSON_Array: |
| 2980 | case cJSON_Object: |
| 2981 | break; |
| 2982 | |
| 2983 | default: |
| 2984 | return false; |
| 2985 | } |
| 2986 | |
| 2987 | /* identical objects are equal */ |
| 2988 | if (a == b) |
| 2989 | { |
| 2990 | return true; |
| 2991 | } |
| 2992 | |
| 2993 | switch (a->type & 0xFF) |
| 2994 | { |
| 2995 | /* in these cases and equal type is enough */ |
| 2996 | case cJSON_False: |
| 2997 | case cJSON_True: |
| 2998 | case cJSON_NULL: |
| 2999 | return true; |
| 3000 | |
| 3001 | case cJSON_Number: |
| 3002 | if (compare_double(a->valuedouble, b->valuedouble)) |
| 3003 | { |
| 3004 | return true; |
| 3005 | } |
| 3006 | return false; |
| 3007 | |
| 3008 | case cJSON_String: |
| 3009 | case cJSON_Raw: |
| 3010 | if ((a->valuestring == NULL) || (b->valuestring == NULL)) |
| 3011 | { |
| 3012 | return false; |
| 3013 | } |
| 3014 | if (strcmp(a->valuestring, b->valuestring) == 0) |
| 3015 | { |
| 3016 | return true; |
| 3017 | } |
| 3018 | |
| 3019 | return false; |
| 3020 |
nothing calls this directly
no test coverage detected