aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/simple-test.h44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/simple-test.h b/src/simple-test.h
index d6656ab..9a8d73e 100644
--- a/src/simple-test.h
+++ b/src/simple-test.h
@@ -165,9 +165,11 @@ do { \
} \
} while(0)
-#define SIMPLE_TEST_INTERN_ERR() \
+#define SIMPLE_TEST_INTERN_ERR(file, line) \
do { \
- fprintf(stderr, "err: bad call to internal func"); \
+ fprintf(stderr, "\e[1m :: "); \
+ fprintf(stderr, "%s:%i: \e[31;1merr:\e[m ", file, line); \
+ fprintf(stderr, "bad call to internal func\n"); \
exit(1); \
} while(0)
@@ -193,16 +195,8 @@ void simple_test_assert_bool(char *sarg1, char *sarg2,
"%s", sarg1, sarg2,
arg1 ? "true" : "false", arg2 ? "true" : "false");
break;
- case SIMPLE_TEST_G:
- SIMPLE_TEST_INTERN_ERR();
- case SIMPLE_TEST_GEQ:
- SIMPLE_TEST_INTERN_ERR();
- case SIMPLE_TEST_L:
- SIMPLE_TEST_INTERN_ERR();
- case SIMPLE_TEST_LEQ:
- SIMPLE_TEST_INTERN_ERR();
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -247,7 +241,7 @@ void simple_test_assert_int(char *sarg1, char *sarg2,
"%" PRIiMAX, sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -292,7 +286,7 @@ void simple_test_assert_uint(char *sarg1, char *sarg2,
"%" PRIuMAX, sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -337,7 +331,7 @@ void simple_test_assert_hex(char *sarg1, char *sarg2,
"%" PRIxMAX, sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -382,7 +376,7 @@ void simple_test_assert_float(char *sarg1, char *sarg2,
"%Lg", sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -427,7 +421,7 @@ void simple_test_assert_ptr(char *sarg1, char *sarg2,
"%p", sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -476,7 +470,7 @@ void simple_test_assert_char(char *sarg1, char *sarg2,
"‘%s’", sarg1, sarg2, buf1, buf2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -521,7 +515,7 @@ void simple_test_assert_str(char *sarg1, char *sarg2,
"‘%s’", sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -570,7 +564,7 @@ void simple_test_assert_wchar(char *sarg1, char *sarg2,
"‘%ls’", sarg1, sarg2, buf1, buf2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
@@ -615,38 +609,42 @@ void simple_test_assert_wstr(char *sarg1, char *sarg2,
"‘%ls’", sarg1, sarg2, arg1, arg2);
break;
default:
- SIMPLE_TEST_INTERN_ERR();
+ SIMPLE_TEST_INTERN_ERR(file, line);
}
}
#define SIMPLE_TEST_GENERIC_CAST(arg) \
_Generic((arg), \
+ bool: (bool)(arg), \
int8_t: (intmax_t)(arg), int16_t: (intmax_t)(arg), int32_t: (intmax_t)(arg), \
int64_t: (intmax_t)(arg), \
uint8_t: (uintmax_t)(arg), uint16_t: (uintmax_t)(arg), uint32_t: (uintmax_t)(arg), \
uint64_t: (uintmax_t)(arg), \
float: (long double)(arg), double: (long double)(arg), \
long double: (long double)(arg) \
- )
+ )
#define SIMPLE_TEST_GENERIC_NOT(arg) \
_Generic((arg), \
+ bool: false, \
int8_t: 0, int16_t: 0, int32_t: 0, int64_t: 0, \
uint8_t: 0, uint16_t: 0, uint32_t: 0, uint64_t: 0, \
float: 0.0, double: 0.0, \
long double: 0.0 \
- )
+ )
#define SIMPLE_TEST_GENERIC_NOT_STR(arg) \
_Generic((arg), \
+ bool: "false", \
int8_t: "0", int16_t: "0", int32_t: "0", int64_t: "0", \
uint8_t: "0", uint16_t: "0", uint32_t: "0", uint64_t: "0", \
float: "0.0", double: "0.0", \
long double: "0.0" \
- )
+ )
#define SIMPLE_TEST_GENERIC_FUNCCALL(sarg1, sarg2, arg1, arg2, cond) \
_Generic((arg2), \
+ bool: simple_test_assert_bool, \
int8_t: simple_test_assert_int, int16_t: simple_test_assert_int, \
int32_t: simple_test_assert_int, int64_t: simple_test_assert_int, \
uint8_t: simple_test_assert_uint, uint16_t: simple_test_assert_uint, \