Debug
This commit is contained in:
parent
1f78947c38
commit
d7829338ca
|
@ -2,10 +2,17 @@
|
|||
|
||||
tmp_out="$(mktemp)"
|
||||
|
||||
grep -A9999 -- "[S]TART_OF_C_FILE" "${0}" | cc -Wall -Wextra -Werror -o "${tmp_out}" -xc "${0%_test.c}.c" -
|
||||
if [ -f "${0%_test.c}.c" ]; then
|
||||
echo "THIS"
|
||||
SRC="${0%_test.c}.c"
|
||||
else
|
||||
echo "THAT"
|
||||
SRC="$($(type -P basename) -- "${0%_test.c}.c")"
|
||||
fi
|
||||
grep -A9999 -- "[S]TART_OF_C_FILE" "${0}" | cc -Wall -Wextra -Werror -o "${tmp_out}" -xc "${SRC}" -
|
||||
|
||||
if [ ! -f "${tmp_out}" ]; then
|
||||
printf "\e[31m%s\e[m\n" "Could not compile"
|
||||
if [ ! "${?}" = "0" ] || [ ! -f "${tmp_out}" ]; then
|
||||
printf "\e[101;37m%s\e[m\n" "Could not compile"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -17,12 +24,14 @@ exit -- "${exit_status}"
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define test(expected_string, func, ...) \
|
||||
#define test(out_prefix, expected_string, func, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "%s", expected_string); \
|
||||
fprintf(stderr, "Case:%s:%s", out_prefix, expected_string); \
|
||||
fflush(stderr); \
|
||||
int old_stderr_fd = dup(2); \
|
||||
dup2(1, 2); \
|
||||
fprintf(stdout, "Case:%s:", out_prefix); \
|
||||
fflush(stdout); \
|
||||
func(__VA_ARGS__); \
|
||||
fflush(stdout); \
|
||||
dup2(old_stderr_fd, 2); \
|
||||
|
@ -31,7 +40,17 @@ exit -- "${exit_status}"
|
|||
int ft_isalpha(int c);
|
||||
|
||||
int main(){
|
||||
test("0\n", printf, "%d\n", ft_isalpha(96));
|
||||
test("Nonzero: 2\n", printf, "Nonzero: %d\n", ft_isalpha(97));
|
||||
test( "'a'", "1\n", printf, "%d\n", ft_isalpha('a'));
|
||||
test( "'A'", "1\n", printf, "%d\n", ft_isalpha('A'));
|
||||
test( "'m'", "1\n", printf, "%d\n", ft_isalpha('m'));
|
||||
test( "'M'", "1\n", printf, "%d\n", ft_isalpha('M'));
|
||||
test( "'z'", "1\n", printf, "%d\n", ft_isalpha('z'));
|
||||
test( "'Z'", "1\n", printf, "%d\n", ft_isalpha('Z'));
|
||||
test( "0", "0\n", printf, "%d\n", ft_isalpha(0));
|
||||
test( "1", "0\n", printf, "%d\n", ft_isalpha(1));
|
||||
test("'a' - 1", "0\n", printf, "%d\n", ft_isalpha('a' - 1));
|
||||
test("'A' - 1", "0\n", printf, "%d\n", ft_isalpha('A' - 1));
|
||||
test("'z' + 1", "0\n", printf, "%d\n", ft_isalpha('z' + 1));
|
||||
test("'Z' + 1", "0\n", printf, "%d\n", ft_isalpha('Z' + 1));
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue