| 3070 | } |
| 3071 | |
| 3072 | CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) |
| 3073 | { |
| 3074 | if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF))) |
| 3075 | { |
| 3076 | return false; |
| 3077 | } |
| 3078 | |
| 3079 | /* check if type is valid */ |
| 3080 | switch (a->type & 0xFF) |
| 3081 | { |
| 3082 | case cJSON_False: |
| 3083 | case cJSON_True: |
| 3084 | case cJSON_NULL: |
| 3085 | case cJSON_Number: |
| 3086 | case cJSON_String: |
| 3087 | case cJSON_Raw: |
| 3088 | case cJSON_Array: |
| 3089 | case cJSON_Object: |
| 3090 | break; |
| 3091 | |
| 3092 | default: |
| 3093 | return false; |
| 3094 | } |
| 3095 | |
| 3096 | /* identical objects are equal */ |
| 3097 | if (a == b) |
| 3098 | { |
| 3099 | return true; |
| 3100 | } |
| 3101 | |
| 3102 | switch (a->type & 0xFF) |
| 3103 | { |
| 3104 | /* in these cases and equal type is enough */ |
| 3105 | case cJSON_False: |
| 3106 | case cJSON_True: |
| 3107 | case cJSON_NULL: |
| 3108 | return true; |
| 3109 | |
| 3110 | case cJSON_Number: |
| 3111 | if (compare_double(a->valuedouble, b->valuedouble)) |
| 3112 | { |
| 3113 | return true; |
| 3114 | } |
| 3115 | return false; |
| 3116 | |
| 3117 | case cJSON_String: |
| 3118 | case cJSON_Raw: |
| 3119 | if ((a->valuestring == NULL) || (b->valuestring == NULL)) |
| 3120 | { |
| 3121 | return false; |
| 3122 | } |
| 3123 | if (strcmp(a->valuestring, b->valuestring) == 0) |
| 3124 | { |
| 3125 | return true; |
| 3126 | } |
| 3127 | |
| 3128 | return false; |
| 3129 |
nothing calls this directly
no test coverage detected