Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am in need of some help with this. 1) Implement a random tester for the function testme() in testme.c (see below) that is capable

I am in need of some help with this.

1) Implement a random tester for the function testme() in testme.c (see below) that is capable of printing the error message. You should implement inputChar() and inputString() to produce random values. 2) Write up the development of your random tester and how it finds/prints the error message as randomstring.pdf. The randomstring.pdf is a text file that outlines how you developed your solution and how it works. 3) Create a Makefile and add a rule in the Makefile that will compile and execute the testme.c file. Helpful hints: You can choose and design your input pool (such as, string size (random or fixed), include every characters in the ASCII code, include every lowercase letter in the alphabet, or include only the letters used in the target statement, etc.). Your random test generator should not take more than five minutes to achieve the coverage goal.

test.c

#include

#include

#include

#include

char inputChar()

{

// TODO: rewrite this function

return ' ';

}

char *inputString()

{

// TODO: rewrite this function

return "";

}

void testme()

{

int tcCount = 0;

char *s;

char c;

int state = 0;

while (1)

{

tcCount++;

c = inputChar();

s = inputString();

printf("Iteration %d: c = %c, s = %s, state = %d ", tcCount, c, s, state);

if (c == '[' && state == 0) state = 1;

if (c == '(' && state == 1) state = 2;

if (c == '{' && state == 2) state = 3;

if (c == ' '&& state == 3) state = 4;

if (c == 'a' && state == 4) state = 5;

if (c == 'x' && state == 5) state = 6;

if (c == '}' && state == 6) state = 7;

if (c == ')' && state == 7) state = 8;

if (c == ']' && state == 8) state = 9;

if (s[0] == 'r' && s[1] == 'e' && s[2] == 's' && s[3] == 'e' && s[4] == 't' && s[5] == '\0' && state == 9)

{

printf("error ");

exit(200);

}

}

}

int main(int argc, char *argv[])

{

srand(time(NULL));

testme();

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1.08s+1.02b predicts the end-of-year value of a

Answered: 1 week ago

Question

5. Wyeth Pharmaceuticals

Answered: 1 week ago