Cody

Problem 44631. Make your own Test Suite (part 0)

Solution 1555746

Submitted on 10 Jun 2018 by David Verrelli
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%assessFunctionAbsence('sind', 'FileName','testSuite.m')

2   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(angle);\n'); fclose(fileID); status_correct = 'pass'; status = 'pass'; testSuite() try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

3   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(angle + eps(angle));\n'); fclose(fileID); status_correct = 'pass'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

4   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sin(angle * pi / 180);\n'); fclose(fileID); status_correct = 'pass'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

5   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = 1 ./ cscd(angle);\n'); fclose(fileID); status_correct = 'pass'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

6   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sin(angle * 3.14 / 180);\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

7   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sin(angle * (22/7) / 180);\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

8   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(angle + 10000*eps(angle));\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

9   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = cosd(angle);\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

10   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(angle*sign(angle));\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

11   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = -sind(angle*sign(angle));\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

12   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(angle)*sign(sind(angle));\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

13   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' s = sind(fix(angle));\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

14   Pass
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); fprintf(fileID,' inc=0;\n'); fprintf(fileID,' if mod(angle,1)==0, inc=1; end;\n'); fprintf(fileID,' s = sind(angle + inc);\n'); fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

status = 'fail'

Suggested Problems

More from this Author31

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!