Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added projects/.DS_Store
Binary file not shown.
Binary file added projects/alabidif/.DS_Store
Binary file not shown.
Binary file added projects/alabidif/quiz/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions projects/alabidif/quiz/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CFLAGS= -Wall -fpic -coverage -lm -std=c99

testme:
-gcc -o testme -g testme.c $(CFLAGS)
-testme >> testresults.out
-gcov testme.c -b -f >> testresults.out
clean:
-rm -f testme *.gcov *.gcda *.gcno *.o
Binary file added projects/alabidif/quiz/randomstring.pdf
Binary file not shown.
65 changes: 65 additions & 0 deletions projects/alabidif/quiz/testme.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>

char inputChar()
{
// TODO: rewrite this function
int randInt = (rand() % 95) + 32;
char randChar = (char) randInt;
return randChar;
}

char *inputString()
{
// TODO: rewrite this function
char randString[6];
for (int i = 0; i < 5; i++) {
randString[i] = (rand() % 16) + 101;
}
randString[5]='\0';
char *inString = randString;
return inString;
}

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\n", 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;
}