- Test 2pi tests whether the computed and expected values for an angle of radians
are equal within an absolute tolerance of 1e-6 or a relative tolerance 0.1%. - Test pi over 4 equality tests whether the sine and cosine of are equal
within a relative tolerance of 0.1%.
- Test matches MATLAB fcn tests whether the computed sine and cosine of
are equal to the values from the sin and cos functions within a relative tolerance of
0.1%.
Run Tests
Execute the runtests function to run the four tests in approxSinCosTest.m. The
runtests function executes each test individually. If one test fails, MATLAB still runs the
remaining tests. If you execute approxSinCosTest as a script instead of using
runtests, MATLAB halts execution of the entire script if it encounters a failed assertion.
Additionally, when you run tests using the runtests function, MATLAB provides
informative test diagnostics.
results = runtests('approxSinCosTest');
Running approxSinCosTest
....
Done approxSinCosTest
All the tests pass.
Create a table of test results.
rt = table(results)
rt =
4x6 table
Name Passed Failed Incomplete Duration Details
'approxSinCosTest/Test0rad' true false false 0.64126 [1x1 struct]
'approxSinCosTest/Test2pi' true false false 0.045495 [1x1 struct]
'approxSinCosTest/TestPiOver4Equality' true false false 0.040887 [1x1 struct]
Write Script-Based Test Using Local Functions