MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Introduce an Error in quadraticSolver.m and Run Tests


Cause one of the tests to fail by forcing roots in quadraticSolver.m to be real. Before
ending the function, add the line: roots = real(roots);. (Do not change
solverTest.m.) Save the file and run the tests.


results = runtests('solverTest.m')


Running solverTest
.


Verification failed in solverTest/testImaginarySolution.




Framework Diagnostic:


verifyEqual failed.
--> Complexity does not match.


Actual Complexity:
Real
Expected Complexity:
Complex


Actual Value:
-1 -1
Expected Value:
-1.000000000000000 + 3.000000000000000i -1.000000000000000 - 3.000000000000000i




Stack Information:


In C:\work\solverTest.m (testImaginarySolution) at 14


.
Done solverTest




Failure Summary:


Name Failed Incomplete Reason(s)


solverTest/testImaginarySolution X Failed by verification.


results =


1x2 TestResult array with properties:


Name
Passed
Failed
Incomplete
Duration


Write Simple Test Case Using Functions
Free download pdf