From 9d56f1787046951075d0053738edcc05d8eda0dd Mon Sep 17 00:00:00 2001 From: Aleksei Chubukov Date: Thu, 7 Dec 2023 20:07:15 +0400 Subject: [PATCH] overtime --- ex00/dict_struct.c | 39 +++++++++++++++++++++++++++++++++++++++ ex00/dict_struct.h | 34 ++++++++++++++++++++++++++++++++++ ex00/ft_open.h | 30 ++++++++++++++++++++++++++++++ tests/test_ft_open.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 ex00/dict_struct.c create mode 100644 ex00/dict_struct.h create mode 100644 ex00/ft_open.h create mode 100644 tests/test_ft_open.c diff --git a/ex00/dict_struct.c b/ex00/dict_struct.c new file mode 100644 index 0000000..83847d5 --- /dev/null +++ b/ex00/dict_struct.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* dict_struct.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/03 20:35:11 by achubuko #+# #+# */ +/* Updated: 2023/12/03 23:07:41 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "dict_struct.h" + +t_dict *dict_create(void) +{ + t_dict *d; + + d = malloc(sizeof(t_dict)); + d->size = 0; + return (d); +} + +void dict_destroy(t_dict *dict) +{ + free(dict); +} + +void dict_update(t_dict *d, char *path) +{ +} + +t_dict *dict_create_default(char *path) +{ + t_dict *d; + + d = dict_create(); + dict_update(d, path); + return (d); +} diff --git a/ex00/dict_struct.h b/ex00/dict_struct.h new file mode 100644 index 0000000..e1a2cf0 --- /dev/null +++ b/ex00/dict_struct.h @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* dict_struct.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/03 20:36:01 by achubuko #+# #+# */ +/* Updated: 2023/12/03 22:20:58 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef DICT_STRUCT_H +# define DICT_STRUCT_H +# include + +typedef struct s_dictitem +{ + unsigned int num_significant; + unsigned int num_base; + char *text; +} t_dictitem; + +typedef struct s_dict +{ + int size; + t_dictitem dict[42]; +} t_dict; + +t_dict *dict_create_default(char *path); +void dict_update(t_dict *d, char *path); +void dict_destroy(t_dict *dict); +void dict_init_default(t_dict *d, char *path); +t_dict *dict_create(void); +#endif diff --git a/ex00/ft_open.h b/ex00/ft_open.h new file mode 100644 index 0000000..7735139 --- /dev/null +++ b/ex00/ft_open.h @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_open.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/03 19:51:40 by achubuko #+# #+# */ +/* Updated: 2023/12/03 23:14:56 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef FT_OPEN_H +# define FT_OPEN_H +# include +# include +# include + +typedef struct s_file +{ + int descriptor; + char *read_window; + size_t read_window_cursor; + size_t read_window_size; + size_t read_size; + char *buffer; + size_t buffer_size; +} t_file; +t_file *ft_open(char *path); +char *ft_dispence_line(t_file *f); +#endif diff --git a/tests/test_ft_open.c b/tests/test_ft_open.c new file mode 100644 index 0000000..b29b531 --- /dev/null +++ b/tests/test_ft_open.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* test_ft_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/03 22:39:20 by achubuko #+# #+# */ +/* Updated: 2023/12/03 22:50:28 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "unity.h" +#include "ft_open.h" + +t_file *g_f; + +void setUp(void) +{ + + g_f = ft_open("test_ft_open.txt"); +} + +void tearDown(void) +{ + close(g_f->descriptor); + free(g_f); +} + +void test_ft_dispence_line_once(void) +{ + TEST_ASSERT_EQUAL_STRING("hello World!", ft_dispence_line(g_f)); +} + +int main(void) +{ + UNITY_BEGIN(); + RUN_TEST(test_ft_dispence_line_once); + return (UNITY_END()); +}