mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix: does not compile
This commit is contained in:
parent
174449cde7
commit
63df02aec5
7 changed files with 54 additions and 40 deletions
|
|
@ -3,20 +3,20 @@
|
|||
/* ::: :::::::: */
|
||||
/* expansion.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/23 15:00:18 by jguelen #+# #+# */
|
||||
/* Updated: 2025/03/01 11:07:17 by jguelen ### ########.fr */
|
||||
/* Created: 2025/03/06 13:01/15 by khais #+# #+# */
|
||||
/* Updated: 2025/03/06 13:01:15 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include "testutil.h"
|
||||
#include "../src/subst/subst.h"
|
||||
#include "../src/subst/replace_substr.h"
|
||||
#include "../../env/env.h"
|
||||
#include "../../env/env_manip.h"
|
||||
#include "../src/subst/subst.h"
|
||||
#include "../src/env/env.h"
|
||||
#include "../src/env/env_manip.h"
|
||||
|
||||
/*
|
||||
** Test file for the different expansion/substitution types of minishell.
|
||||
|
|
@ -46,48 +46,52 @@ static void test_insert_instr(void)
|
|||
//Test to be remade since structures changed in the function calls and returns.
|
||||
static void test_env_variable_expansion(void)
|
||||
{
|
||||
char *token;
|
||||
char *tk;
|
||||
t_worddesc *token;
|
||||
t_worddesc *tk;
|
||||
t_env *env;
|
||||
struct s_minishell app;
|
||||
|
||||
token = ft_strdup("$USER");
|
||||
app.last_return_value = 0;
|
||||
|
||||
token = worddesc_create(ft_strdup("$USER"), W_HASDOLLAR);
|
||||
if (!token)
|
||||
assert("ft_strdup failed" && false);
|
||||
env = NULL;
|
||||
app.env = env;
|
||||
env = env_set_entry(&env, "USER", "jguelen");
|
||||
if (env == NULL)
|
||||
assert("malloc failed" && false);
|
||||
env = env_set_entry(&env, "_canard", "coing coing");
|
||||
if (!env)
|
||||
assert("malloc failed: slipped on a duck" && false);
|
||||
tk = word_var_expansion(&token, env);
|
||||
tk = word_var_expansion(token, &app);
|
||||
if (!tk)
|
||||
assert("internal word_var_expansion failure" && false);
|
||||
assert_strequal("jguelen", tk);
|
||||
assert_strequal("jguelen", tk->word);
|
||||
free(token);
|
||||
token = ft_strdup("\"$_caneton\"");
|
||||
token = worddesc_create(ft_strdup("\"$_caneton\""), W_HASDOLLAR);
|
||||
if (!token)
|
||||
assert("ft_strdup failed" && false);
|
||||
tk = word_var_expansion(&token, env);
|
||||
tk = word_var_expansion(token, &app);
|
||||
if (!tk)
|
||||
assert("internal word_var_expansion failure" && false);
|
||||
assert_strequal("\"\"", tk);
|
||||
assert_strequal("\"\"", tk->word);
|
||||
free(token);
|
||||
token = ft_strdup("$_canard$USER$''$USER\"\"\"$_canard\"$");
|
||||
token = worddesc_create(ft_strdup("$_canard$USER$''$USER\"\"\"$_canard\"$"), W_HASDOLLAR);
|
||||
if (!token)
|
||||
assert("ft_strdup failed" && false);
|
||||
tk = word_var_expansion(token, env);
|
||||
tk = word_var_expansion(token, &app);
|
||||
if (!tk)
|
||||
assert("internal word_var_expansion failure" && false);
|
||||
assert_strequal("coing coingjguelen''jguelencoing coing$", tk);
|
||||
assert_strequal("coing coingjguelen''jguelencoing coing$", tk->word);
|
||||
free(token);
|
||||
token = ft_strdup("$_can'a'rd");
|
||||
token = worddesc_create(ft_strdup("$_can'a'rd"), W_HASDOLLAR);
|
||||
if (!token)
|
||||
assert("ft_strdup failed" && false);
|
||||
tk = word_var_expansion(token, env);
|
||||
tk = word_var_expansion(token, &app);
|
||||
if (!tk)
|
||||
assert("internal word_var_expansion failure" && false);
|
||||
assert_strequal("'a'rd", tk);
|
||||
assert_strequal("'a'rd", tk->word);
|
||||
free(token);
|
||||
env_destroy(env);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue