, , , ,

[SOLVED] Sft221 – workshop 1

$25

File Name: Sft221_–_workshop_1.zip
File Size: 197.82 KB

Categories: , , , , Tags: , , , ,
5/5 - (1 vote)

• Understandthe difference between testing anddebugging.
• How to do simple software tests.
• How to do simple debugging.
• Appreciate the difficulty in testing and debugging.The following code contains a function to determine if a string starts with anotherstring and a second
function to test if a string ends with another string. The developer wrote twotests for the functions and
concluded that they work.Your job is to:
• Testthe code to determine if it works correctly:
o Show the test code for every test anddescribe what you are testing.
o Present the result of the test and your interpretationof the result and an explanation of
how this result happened if the result was not what you expected.
o Inspectthe code to find any bugs not revealed in testing.• Debug the code:
o Use whatevertools you like to determine the cause of an errors you found in the code
regardless of the means you used to find the error.
o Fix the code and explain what the error was and how you fixed it.
Here is the code you will be working on.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
/**
* Determine if the string s starts with the string prefix.
* @param s – the string to see if it starts with prefix
* @param prefix – the prefix to test
* @returns true if the strings begins with the prefix.
*/
int startsWith(const char s[], const char prefix[])
{
char buf[25];
int i;
int sz = strlen(prefix);
for (i = 0; i < sz; i++)
{
buf[i] = s[i];
}
buf[sz] = ‘’;
return 0 == strcmp(buf, prefix);
}
/**
* Determine if the string s ends with the string suffix.
* @param s – the string to see if it ends with suffix
* @param suffix – the suffix to test
* @returns true if the strings ends with the suffix.
*/
int endsWith(const char s[], const char suffix[])
{
int sz = strlen(suffix);
int slen = strlen(s);
return 0 == strcmp(s + slen – sz, suffix);
}
int main(void)
{
char s1[] = { “upended” };
char prefix[] = { “up” };
char suffix[] = { “ed” };
printf(“%s does %s start with %s
”,
s1, startsWith(s1, prefix) ? “” : ” not”, prefix);
printf(“%s does %s end with %s
”,
s1, endsWith(s1, suffix) ? “” : ” not”, suffix);
return 0;
}Deliverables
Due Date:
This workshop is due at 11:59 pm 2 days after yourlab day. Late submits will not be accepted.
Explanations should not be trivial but state where the bug is and under what conditions it can occur.
Similarly, explanation of bug fixes should explore the bug in depth, state when it could happen and
how the fix to the code will prevent it from happening in the future. Reflections should consider the
questions in depth and not be trivial. Some reflections might require research to properly answerthe
question. As a rough guideline, the answerto each reflection questions should be about 100 words in
length.You should submit:
Testing and Debugging Results
• A list of the tests you performed including:
o The code for the test(which might be a single function call with parameters)
o A description of what you were testing for
o The result of the testo Your interpretationof the test result and an explanation of what happened if the result
was not what you expected.
o State whether thistest hasidentified a bug or not.
• After inspecting the code:
o Identify any additional bugs you found,
o If you wrote a testtoverify this was a bug, include the code,
o Explain how this bug could cause erroneousresult or programfailure.• For every bug identified in the firsttwo sections:
o State which bug you are fixing,
o Show the code before and after you fixed it. Do not repeat all of the code, but just the
lines modified to fix this particular bug.
o An explanation of how your modification fixes the bug.A Reflection, Research and Assessment
• A reflection where you consider whether testing orinspection identified more bugs in this case.
State why you think one way worked better than the other. How could you improve the
technique that worked less well?
• Did you find it difficult to find the bugs in this assignment? If not, what helped find them
quickly? If you did find it difficult, what made finding the bugs so difficult?Marking Rubric
Comprehensiveness of test cases 10%
Explanation of erroneous testresults 15%
Explanation of bugs discovered by inspection 15%
Discovered at least 4 bugs 15%
Quality of bug fixes 10%
Explanation of how bug fix works 15%
Reflection 20%

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Sft221 – workshop 1
$25