@@ -1122,6 +1122,22 @@ void testMonotonicity(SimTK::Matrix mcfSample)
1122
1122
cout << endl;
1123
1123
}
1124
1124
1125
+ /*
1126
+ 5. Tests the output when NaN is the input.
1127
+ */
1128
+ template <typename F>
1129
+ void testMuscleCurveNaNBehavior (const F& curve)
1130
+ {
1131
+ cout << " TEST: NaN behavior. " << endl;
1132
+
1133
+ // Curve value at NaN gives NaN.
1134
+ SimTK_TEST (std::isnan (curve.calcValue (SimTK::NaN)));
1135
+ SimTK_TEST (std::isnan (curve.calcDerivative (SimTK::NaN, 1 )));
1136
+ SimTK_TEST (std::isnan (curve.calcDerivative (SimTK::NaN, 2 )));
1137
+
1138
+ cout << " passed testing NaN behavior." << endl;
1139
+ }
1140
+
1125
1141
// ______________________________________________________________________________
1126
1142
/* *
1127
1143
* Create a muscle bench marking system. The bench mark consists of a single muscle
@@ -1209,8 +1225,10 @@ int main(int argc, char* argv[])
1209
1225
testMuscleCurveC2Continuity (tendonCurve,tendonCurveSample);
1210
1226
// 4. Test for monotonicity where appropriate
1211
1227
testMonotonicity (tendonCurveSample);
1228
+ // 5. Test NaN behavior.
1229
+ testMuscleCurveNaNBehavior (tendonCurve);
1212
1230
1213
- // 5 . Testing Exceptions
1231
+ // 6 . Testing Exceptions
1214
1232
cout << endl;
1215
1233
cout << " Exception Testing" << endl;
1216
1234
SimTK_TEST_MUST_THROW (/* SmoothSegmentedFunction* tendonCurveEX
@@ -1279,8 +1297,10 @@ int main(int argc, char* argv[])
1279
1297
// 4. Test for monotonicity where appropriate
1280
1298
1281
1299
testMonotonicity (fiberFLCurveSample);
1300
+ // 5. Test NaN behavior.
1301
+ testMuscleCurveNaNBehavior (fiberFLCurve);
1282
1302
1283
- // 5 . Testing Exceptions
1303
+ // 6 . Testing Exceptions
1284
1304
cout << endl;
1285
1305
cout << " Exception Testing" << endl;
1286
1306
SimTK_TEST_MUST_THROW (/* SmoothSegmentedFunction* fiberFLCurveEX
@@ -1348,7 +1368,9 @@ int main(int argc, char* argv[])
1348
1368
// 4. Test for monotonicity where appropriate
1349
1369
1350
1370
testMonotonicity (fiberCECurveSample);
1351
- // 5. Testing Exceptions
1371
+ // 5. Test NaN behavior.
1372
+ testMuscleCurveNaNBehavior (fiberCECurve);
1373
+ // 6. Testing Exceptions
1352
1374
cout << endl;
1353
1375
cout << " Exception Testing" << endl;
1354
1376
SimTK_TEST_MUST_THROW (/* SmoothSegmentedFunction* fiberCECurveEX
@@ -1412,7 +1434,9 @@ int main(int argc, char* argv[])
1412
1434
testMuscleCurveC2Continuity (fiberCEPhiCurve,fiberCEPhiCurveSample);
1413
1435
// 4. Test for monotonicity where appropriate
1414
1436
testMonotonicity (fiberCEPhiCurveSample);
1415
- // 5. Testing Exceptions
1437
+ // 5. Test NaN behavior.
1438
+ testMuscleCurveNaNBehavior (fiberCEPhiCurve);
1439
+ // 6. Testing Exceptions
1416
1440
cout << endl;
1417
1441
cout << " Exception Testing" << endl;
1418
1442
SimTK_TEST_MUST_THROW (/* SmoothSegmentedFunction* fiberCEPhiCurveEX
@@ -1485,7 +1509,9 @@ int main(int argc, char* argv[])
1485
1509
// 4. Test for monotonicity where appropriate
1486
1510
1487
1511
testMonotonicity (fiberCECosPhiCurveSample);
1488
- // 5. Test exceptions
1512
+ // 5. Test NaN behavior.
1513
+ testMuscleCurveNaNBehavior (fiberCECosPhiCurve);
1514
+ // 6. Test exceptions
1489
1515
cout << endl;
1490
1516
cout << " Exception Testing" << endl;
1491
1517
SimTK_TEST_MUST_THROW (/* SmoothSegmentedFunction* fiberCECosPhiCurveEX
@@ -1575,7 +1601,9 @@ int main(int argc, char* argv[])
1575
1601
// 4. Test for monotonicity where appropriate
1576
1602
1577
1603
testMonotonicity (fiberFVCurveSample);
1578
- // 5. Exception testing
1604
+ // 5. Test NaN behavior.
1605
+ testMuscleCurveNaNBehavior (fiberFVCurve);
1606
+ // 6. Exception testing
1579
1607
cout << endl;
1580
1608
cout << " Exception Testing" << endl;
1581
1609
@@ -1686,8 +1714,10 @@ int main(int argc, char* argv[])
1686
1714
// 4. Test for monotonicity where appropriate
1687
1715
1688
1716
testMonotonicity (fiberFVInvCurveSample);
1717
+ // 5. Test NaN behavior.
1718
+ testMuscleCurveNaNBehavior (fiberFVInvCurve);
1689
1719
1690
- // 5 . Testing the exceptions
1720
+ // 6 . Testing the exceptions
1691
1721
1692
1722
// 5. Exception testing
1693
1723
cout << endl;
0 commit comments