tests: More refactoring, add helper header to every test, override exit for better error reporting
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char * s = "azAZ9."; // test boundaries
|
||||
long l = a64l(s);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char * ptr = (char *)malloc(256);
|
||||
printf("malloc %p\n", ptr);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
double d = atof("-3.14");
|
||||
printf("%f\n", d);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
printf("%d\n", atoi(" -42"));
|
||||
printf("%d\n", atoi(" +555"));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int int_cmp(const void* a, const void* b) {
|
||||
return *(const int*) a - *(const int*) b;
|
||||
}
|
||||
|
||||
+18
-15
@@ -1,20 +1,23 @@
|
||||
#include <stdlib.h>
|
||||
volatile float f;
|
||||
volatile long double ld;
|
||||
volatile unsigned long long ll;
|
||||
lldiv_t mydivt;
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
volatile float f;
|
||||
volatile long double ld;
|
||||
volatile unsigned long long ll;
|
||||
lldiv_t mydivt;
|
||||
|
||||
int main(void) {
|
||||
char* tmp;
|
||||
f = strtof("gnu", &tmp);
|
||||
ld = strtold("gnu", &tmp);
|
||||
ll = strtoll("gnu", &tmp, 10);
|
||||
ll = strtoull("gnu", &tmp, 10);
|
||||
ll = llabs(10);
|
||||
mydivt = lldiv(10,1);
|
||||
ll = mydivt.quot;
|
||||
ll = mydivt.rem;
|
||||
ll = atoll("10");
|
||||
_Exit(0);
|
||||
char* tmp;
|
||||
f = strtof("gnu", &tmp);
|
||||
ld = strtold("gnu", &tmp);
|
||||
ll = strtoll("gnu", &tmp, 10);
|
||||
ll = strtoull("gnu", &tmp, 10);
|
||||
ll = llabs(10);
|
||||
mydivt = lldiv(10,1);
|
||||
ll = mydivt.quot;
|
||||
ll = mydivt.rem;
|
||||
ll = atoll("10");
|
||||
_Exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
//puts(getenv("SHELL"));
|
||||
//puts(getenv("CC"));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char* file_name = (char*) calloc(18, sizeof(char));
|
||||
strcpy(file_name, "tempXXXXXX.suffix");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char* string = (char*) calloc(20, sizeof(char));
|
||||
strcpy(string, "tempXXXXXX");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
printf("%d\n", rand());
|
||||
srand(259);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char* path = realpath("stdlib/realpath.c", NULL);
|
||||
if (!path) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
char* endptr = 0;
|
||||
double d;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
printf("%ld\n", strtol(" -42", NULL, 0));
|
||||
printf("%ld\n", strtol(" +555", NULL, 0));
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
printf("%ld\n", strtoul(" -42", NULL, 0));
|
||||
printf("%ld\n", strtoul(" +555", NULL, 0));
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
|
||||
int main(void) {
|
||||
system("echo test of system");
|
||||
int status = system("echo test of system");
|
||||
ERROR_IF(system, status, == -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user