Cody

Solution 1721562

Submitted on 5 Feb 2019
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
% NOTE: You may notice that the user function has been named "SINE", % in uppercase. That is an extra precaution to avoid accidentally % triggering an error due to a banned 'word' (sequence of characters). % Careful choice of code to check for banned _functions_ is better! assessFunctionAbsence('sind', 'FileName','testSuite.m') assessFunctionAbsence('sin', 'FileName','testSuite.m') assessFunctionAbsence('cscd', 'FileName','testSuite.m') assessFunctionAbsence('cosd', '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   Fail
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' )

Wrong status

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'

15   Fail
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); if rand() < 0.5, fprintf(fileID,' s = int8(sind(angle));\n'); else fprintf(fileID,' s = int16(sind(angle));\n'); end; fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

Wrong status

16   Fail
fileID = fopen('SINE.m','w'); fprintf(fileID,'function s = SINE(angle)\n'); if rand() < 0.5, fprintf(fileID,' s = int32(sind(angle));\n'); else fprintf(fileID,' s = int64(sind(angle));\n'); end; fclose(fileID); status_correct = 'fail'; status = 'pass'; try testSuite() catch e status = 'fail' end assert( isequal(status, status_correct) , 'Wrong status' )

Wrong status

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

Wrong status