#lizard forgives
| 2806 | |
| 2807 | // #lizard forgives |
| 2808 | CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) |
| 2809 | { |
| 2810 | if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) |
| 2811 | { |
| 2812 | return false; |
| 2813 | } |
| 2814 | |
| 2815 | /* check if type is valid */ |
| 2816 | switch (a->type & 0xFF) |
| 2817 | { |
| 2818 | case cJSON_False: |
| 2819 | case cJSON_True: |
| 2820 | case cJSON_NULL: |
| 2821 | case cJSON_Number: |
| 2822 | case cJSON_String: |
| 2823 | case cJSON_Raw: |
| 2824 | case cJSON_Array: |
| 2825 | case cJSON_Object: |
| 2826 | break; |
| 2827 | |
| 2828 | default: |
| 2829 | return false; |
| 2830 | } |
| 2831 | |
| 2832 | /* identical objects are equal */ |
| 2833 | if (a == b) |
| 2834 | { |
| 2835 | return true; |
| 2836 | } |
| 2837 | |
| 2838 | switch (a->type & 0xFF) |
| 2839 | { |
| 2840 | /* in these cases and equal type is enough */ |
| 2841 | case cJSON_False: |
| 2842 | case cJSON_True: |
| 2843 | case cJSON_NULL: |
| 2844 | return true; |
| 2845 | |
| 2846 | case cJSON_Number: |
| 2847 | if (a->valuedouble == b->valuedouble) |
| 2848 | { |
| 2849 | return true; |
| 2850 | } |
| 2851 | return false; |
| 2852 | |
| 2853 | case cJSON_String: |
| 2854 | case cJSON_Raw: |
| 2855 | if ((a->valuestring == NULL) || (b->valuestring == NULL)) |
| 2856 | { |
| 2857 | return false; |
| 2858 | } |
| 2859 | if (strcmp(a->valuestring, b->valuestring) == 0) |
| 2860 | { |
| 2861 | return true; |
| 2862 | } |
| 2863 | |
| 2864 | return false; |
| 2865 |
nothing calls this directly
no test coverage detected