-
Notifications
You must be signed in to change notification settings - Fork 0
/
teststring.c
57 lines (42 loc) · 964 Bytes
/
teststring.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "hw1.h"
#include <string.h>
int test_reverse(char *);
#define DEBUG 1
#undef DEBUG
#ifdef DEBUG
int main(void)
{
char * str2 = "some NUMmbers12345" ;
char i;
i = reverse_string(NULL, strlen(str2));
printf("%d\n",(int) i);
return 0;
}
#endif
#ifndef DEBUG
int main(void)
{
char * str1 = "This is a string.";
char * str2 = "some NUMmbers12345" ;
char * str3 = "Does it reverse \n\0\t correctly?";
test_reverse(str1);
test_reverse(str2);
reverse_string(str3, 31);
/* test_reverse(str3);*/
printf("All asserts pass!\n");
return 0;
}
#endif
int test_reverse(char * str)
{
int i = 0;
int length = strlen(str);
assert(reverse_string(str, length ) == 0);
assert(reverse_string(NULL, length )!= 0);
assert(reverse_string(str, 0 ) != 0);
i = 1;
return i;
}