mirror of
https://github.com/zoriya/ash.git
synced 2026-06-05 19:34:23 +00:00
echo: manage backslashes
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** test_echo.c
|
||||
** File description:
|
||||
** techo
|
||||
*/
|
||||
|
||||
#include <criterion/redirect.h>
|
||||
#include <criterion/criterion.h>
|
||||
#include "builtin.h"
|
||||
|
||||
Test(echo, normal_message, .init = cr_redirect_stdout)
|
||||
{
|
||||
env_t env = {};
|
||||
char *av[] = {"echo", "hello", NULL};
|
||||
builtin_echo(av, &env);
|
||||
cr_assert_stdout_eq_str("hello\n");
|
||||
}
|
||||
|
||||
Test(echo, with_simple_backslash, .init = cr_redirect_stdout)
|
||||
{
|
||||
env_t env = {};
|
||||
char *av[] = {"echo", "\\n", NULL};
|
||||
builtin_echo(av, &env);
|
||||
cr_assert_stdout_eq_str("n\n");
|
||||
}
|
||||
|
||||
Test(echo, with_double_backslash, .init = cr_redirect_stdout)
|
||||
{
|
||||
env_t env = {};
|
||||
char *av[] = {"echo", "\\\\n", NULL};
|
||||
builtin_echo(av, &env);
|
||||
cr_assert_stdout_eq_str("\\n\n");
|
||||
}
|
||||
|
||||
Test(echo, multiple_args, .init = cr_redirect_stdout)
|
||||
{
|
||||
env_t env = {};
|
||||
char *av[] = {"echo", "Hello", "I\'m", "Marvin", NULL};
|
||||
builtin_echo(av, &env);
|
||||
cr_assert_stdout_eq_str("Hello I\'m Marvin\n");
|
||||
}
|
||||
Reference in New Issue
Block a user