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