New template, named side by side view
This commit is contained in:
parent
a99516268a
commit
8fba4d45ad
|
@ -52,6 +52,8 @@ exit -- "${exit_status}"
|
|||
int ft_isalpha(int c);
|
||||
|
||||
int main(){
|
||||
test( "Test output", printf, "\n");
|
||||
expect("Expected output", printf, "\n");
|
||||
test( "'a'", printf, "%d\n", ft_isalpha('a'));
|
||||
expect( "'a'", printf, "%d\n", isalpha('a'));
|
||||
test( "'A'", printf, "%d\n", ft_isalpha('A'));
|
||||
|
|
|
@ -52,6 +52,8 @@ exit -- "${exit_status}"
|
|||
int ft_isdigit(int c);
|
||||
|
||||
int main(){
|
||||
test( "Test output", printf, "\n");
|
||||
expect("Expected output", printf, "\n");
|
||||
test( "'0'", printf, "%d\n", ft_isdigit('0'));
|
||||
expect("'0'", printf, "%d\n", isdigit('0'));
|
||||
test( "'1'", printf, "%d\n", ft_isdigit('1'));
|
||||
|
|
|
@ -22,20 +22,35 @@ exit -- "${exit_status}"
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define test(out_prefix, expected_string, func, ...) \
|
||||
#define test(inp, func, ...) \
|
||||
do { \
|
||||
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); \
|
||||
fprintf(stdout, "Case:%s:", inp); \
|
||||
fflush(stdout); \
|
||||
func(__VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
fflush(stdout); \
|
||||
dup2(old_stderr_fd, 2); \
|
||||
} while(0)
|
||||
|
||||
#define expect(inp, func, ...) \
|
||||
do { \
|
||||
int old_stdout_fd = dup(1); \
|
||||
dup2(2, 1); \
|
||||
fprintf(stderr, "Case:%s:", inp); \
|
||||
fflush(stderr); \
|
||||
func(__VA_ARGS__); \
|
||||
fflush(stderr); \
|
||||
fflush(stdout); \
|
||||
dup2(old_stdout_fd, 1); \
|
||||
} while(0)
|
||||
// Don't delete above this comment
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
int main(){
|
||||
test("dummy", "true\n", printf, "%s\n", "true");
|
||||
test( "Test output", printf, "\n");
|
||||
expect("Expected output", printf, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue