MCPcopy Index your code
hub / github.com/ThrowTheSwitch/Unity / UnityAssertDoubleSpecial

Function UnityAssertDoubleSpecial

src/unity.c:1313–1375  ·  view source on GitHub ↗

-----------------------------------------------*/

Source from the content-addressed store, hash-verified

1311
1312/*-----------------------------------------------*/
1313void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
1314 const char* msg,
1315 const UNITY_LINE_TYPE lineNumber,
1316 const UNITY_FLOAT_TRAIT_T style)
1317{
1318 const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet};
1319 UNITY_INT should_be_trait = ((UNITY_INT)style & 1);
1320 UNITY_INT is_trait = !should_be_trait;
1321 UNITY_INT trait_index = (UNITY_INT)(style >> 1);
1322
1323 RETURN_IF_FAIL_OR_IGNORE;
1324
1325 switch (style)
1326 {
1327 case UNITY_FLOAT_IS_INF:
1328 case UNITY_FLOAT_IS_NOT_INF:
1329 is_trait = UNITY_IS_INF(actual) && (actual > 0);
1330 break;
1331 case UNITY_FLOAT_IS_NEG_INF:
1332 case UNITY_FLOAT_IS_NOT_NEG_INF:
1333 is_trait = UNITY_IS_INF(actual) && (actual < 0);
1334 break;
1335
1336 case UNITY_FLOAT_IS_NAN:
1337 case UNITY_FLOAT_IS_NOT_NAN:
1338 is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
1339 break;
1340
1341 case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
1342 case UNITY_FLOAT_IS_NOT_DET:
1343 is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
1344 break;
1345
1346 case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */
1347 default: /* including UNITY_FLOAT_INVALID_TRAIT */
1348 trait_index = 0;
1349 trait_names[0] = UnityStrInvalidFloatTrait;
1350 break;
1351 }
1352
1353 if (is_trait != should_be_trait)
1354 {
1355 UnityTestResultsFailBegin(lineNumber);
1356 UnityPrint(UnityStrExpected);
1357 if (!should_be_trait)
1358 {
1359 UnityPrint(UnityStrNot);
1360 }
1361 UnityPrint(trait_names[trait_index]);
1362 UnityPrint(UnityStrWas);
1363#ifndef UNITY_EXCLUDE_FLOAT_PRINT
1364 UnityPrintFloat(actual);
1365#else
1366 if (should_be_trait)
1367 {
1368 UnityPrint(UnityStrNot);
1369 }
1370 UnityPrint(trait_names[trait_index]);

Callers

nothing calls this directly

Calls 4

UnityPrintFunction · 0.85
UnityPrintFloatFunction · 0.85
UnityAddMsgIfSpecifiedFunction · 0.85

Tested by

no test coverage detected