overtime
This commit is contained in:
parent
1d9fc70142
commit
9d56f17870
39
ex00/dict_struct.c
Normal file
39
ex00/dict_struct.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* dict_struct.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
34
ex00/dict_struct.h
Normal file
34
ex00/dict_struct.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* dict_struct.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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 <stdlib.h>
|
||||||
|
|
||||||
|
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
|
30
ex00/ft_open.h
Normal file
30
ex00/ft_open.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_open.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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 <unistd.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <stdlib.h>
|
||||||
|
|
||||||
|
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
|
40
tests/test_ft_open.c
Normal file
40
tests/test_ft_open.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* test_ft_utils.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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());
|
||||||
|
}
|
Reference in New Issue
Block a user