tests: More refactoring, add helper header to every test, override exit for better error reporting

This commit is contained in:
Tibor Nagy
2019-02-21 21:13:28 +01:00
parent 6266d29242
commit 9a0ea6ff34
99 changed files with 323 additions and 88 deletions
+2
View File
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
puts("# mem #");
char arr[100];
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char dest1[12] = "hello";
printf("%s\n", strcat(dest1, " world")); // should be hello world
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%s\n", strchr("hello", 'e')); // should be ello
printf("%s\n", strchr("world", 'l')); // should be ld
+2
View File
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <string.h>
#include "test_helpers.h"
int main(void) {
char dst[20];
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char *world = "world";
printf("%ld\n", strcspn("hello", world)); // should be 2
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%d\n", strncmp("a", "aa", 2));
printf("%d\n", strncmp("a", "", 2));
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char* source = "The quick drawn fix jumps over the lazy bug";
+2
View File
@@ -2,6 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "test_helpers.h"
int main(void) {
char s0[] = "hello, world";
char* ptr = strrchr(s0, 'l');
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char *hello = "hello";
char *world = "world";
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
printf("%s\n", strstr("In relibc we trust", "rust"));
printf("%s\n", strstr("In relibc we trust", "libc"));
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, "
"is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n";
+2
View File
@@ -1,6 +1,8 @@
#include <string.h>
#include <stdio.h>
#include "test_helpers.h"
int main(void) {
char source[] = "I'd just like to interject for a moment. What you're referring to as Linux, "
"is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.\n";