MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / UnityAssertDoubleSpecial

Function UnityAssertDoubleSpecial

tests/unity/src/unity.c:903–960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901/*-----------------------------------------------*/
902
903void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
904 const char* msg,
905 const UNITY_LINE_TYPE lineNumber,
906 const UNITY_FLOAT_TRAIT_T style)
907{
908 const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
909 UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
910 UNITY_INT is_trait = !should_be_trait;
911 UNITY_INT trait_index = (UNITY_INT)(style >> 1);
912
913 RETURN_IF_FAIL_OR_IGNORE;
914
915 switch (style)
916 {
917 case UNITY_FLOAT_IS_INF:
918 case UNITY_FLOAT_IS_NOT_INF:
919 is_trait = isinf(actual) && (actual > 0);
920 break;
921 case UNITY_FLOAT_IS_NEG_INF:
922 case UNITY_FLOAT_IS_NOT_NEG_INF:
923 is_trait = isinf(actual) && (actual < 0);
924 break;
925
926 case UNITY_FLOAT_IS_NAN:
927 case UNITY_FLOAT_IS_NOT_NAN:
928 is_trait = isnan(actual) ? 1 : 0;
929 break;
930
931 case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
932 case UNITY_FLOAT_IS_NOT_DET:
933 is_trait = !isinf(actual) && !isnan(actual);
934 break;
935
936 default:
937 trait_index = 0;
938 trait_names[0] = UnityStrInvalidFloatTrait;
939 break;
940 }
941
942 if (is_trait != should_be_trait)
943 {
944 UnityTestResultsFailBegin(lineNumber);
945 UnityPrint(UnityStrExpected);
946 if (!should_be_trait)
947 UnityPrint(UnityStrNot);
948 UnityPrint(trait_names[trait_index]);
949 UnityPrint(UnityStrWas);
950#ifndef UNITY_EXCLUDE_FLOAT_PRINT
951 UnityPrintFloat(actual);
952#else
953 if (should_be_trait)
954 UnityPrint(UnityStrNot);
955 UnityPrint(trait_names[trait_index]);
956#endif
957 UnityAddMsgIfSpecified(msg);
958 UNITY_FAIL_AND_BAIL;
959 }
960}

Callers

nothing calls this directly

Calls 4

UnityPrintFunction · 0.85
UnityPrintFloatFunction · 0.85
UnityAddMsgIfSpecifiedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…