test coverage
This commit is contained in:
parent
54db58d362
commit
3b95608233
23 changed files with 199 additions and 50 deletions
26
demo/misc.c
26
demo/misc.c
|
@ -1,26 +0,0 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
void should_be(int expected, int actual) {
|
||||
if (expected != actual) {
|
||||
printf("Expected %d, but got %d\n", expected, actual);
|
||||
} else {
|
||||
printf("Passed\n");
|
||||
}
|
||||
}
|
||||
|
||||
int* p = 0;
|
||||
int f1() {
|
||||
int a = 1;
|
||||
return *(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(p))))))))))); // p[10]
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int a[15];
|
||||
p = a;
|
||||
for (int i = 0; i < 15; a[i] = i, ++i);
|
||||
p -= 5;
|
||||
should_be(5, f1());
|
||||
should_be(5, a - p);
|
||||
should_be(10, 5);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int strcmp(char* s1, char* s2) {
|
||||
while (*s1 && *s2 && *s1 == *s2) {
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return *s1 - *s2;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char* s1 = "helloworld";
|
||||
char* s2 = "world";
|
||||
printf("%d\n", strcmp(s1, s2));
|
||||
printf("%d\n", strcmp(s1 + 5, s2));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue