| 3007 | } |
| 3008 | |
| 3009 | CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) |
| 3010 | { |
| 3011 | if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) |
| 3012 | { |
| 3013 | return false; |
| 3014 | } |
| 3015 | |
| 3016 | /* check if type is valid */ |
| 3017 | switch (a->type & 0xFF) |
| 3018 | { |
| 3019 | case cJSON_False: |
| 3020 | case cJSON_True: |
| 3021 | case cJSON_NULL: |
| 3022 | case cJSON_Number: |
| 3023 | case cJSON_String: |
| 3024 | case cJSON_Raw: |
| 3025 | case cJSON_Array: |
| 3026 | case cJSON_Object: |
| 3027 | break; |
| 3028 | |
| 3029 | default: |
| 3030 | return false; |
| 3031 | } |
| 3032 | |
| 3033 | /* identical objects are equal */ |
| 3034 | if (a == b) |
| 3035 | { |
| 3036 | return true; |
| 3037 | } |
| 3038 | |
| 3039 | switch (a->type & 0xFF) |
| 3040 | { |
| 3041 | /* in these cases and equal type is enough */ |
| 3042 | case cJSON_False: |
| 3043 | case cJSON_True: |
| 3044 | case cJSON_NULL: |
| 3045 | return true; |
| 3046 | |
| 3047 | case cJSON_Number: |
| 3048 | if (compare_double(a->valuedouble, b->valuedouble)) |
| 3049 | { |
| 3050 | return true; |
| 3051 | } |
| 3052 | return false; |
| 3053 | |
| 3054 | case cJSON_String: |
| 3055 | case cJSON_Raw: |
| 3056 | if ((a->valuestring == NULL) || (b->valuestring == NULL)) |
| 3057 | { |
| 3058 | return false; |
| 3059 | } |
| 3060 | if (strcmp(a->valuestring, b->valuestring) == 0) |
| 3061 | { |
| 3062 | return true; |
| 3063 | } |
| 3064 | |
| 3065 | return false; |
| 3066 |
nothing calls this directly
no test coverage detected