more stuff
This commit is contained in:
parent
678dbd0846
commit
20fcf7d906
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@ -0,0 +1,4 @@
|
||||
root = true
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
4
Makefile
4
Makefile
@ -10,6 +10,8 @@ all_builds := $(foreach e, 00 01 02 03 04 05 06 07 08, build/c00/ex$e) \
|
||||
$(foreach e, 00 01 02 03 04 05 06 07 08, build/c01/ex$e) \
|
||||
$(foreach e, 00 01 02 03 04 05 06 07 08 09 10 11 12, build/c02/ex$e) \
|
||||
|
||||
MAKEFLAGS := -k
|
||||
|
||||
all: norme $(all_builds)
|
||||
build:
|
||||
mkdir $@
|
||||
@ -22,4 +24,4 @@ build/c%: $(OFFSHORE_PROJECTS)/c$$*/*.c $$(OFFSHORE_MAINS)/c$$*.c $$(wildcard $(
|
||||
mkdir -p $(@D)
|
||||
$(CC) -o $@ $(CFLAGS_MANDATORY) -Icommon $(CFLAGS) $^
|
||||
norme: $$(wildcard $(OFFSHORE_PROJECTS)/c*)
|
||||
norminette -R CheckForbiddenSourceHeader $^
|
||||
norminette $^ || true
|
||||
|
43
c02/ex01.c
43
c02/ex01.c
@ -1,25 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex01.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: achubuko <achubuko@student.42yerevan.am> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/27 21:57:45 by achubuko #+# #+# */
|
||||
/* Updated: 2023/11/27 21:59:11 by achubuko ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "tests.h"
|
||||
char *ft_strncpy(char*, char*, size_t);
|
||||
|
||||
char *ft_strncpy(char*, char*, size_t);
|
||||
int main(void)
|
||||
{
|
||||
char s1[100] = TEST_SOURCE;
|
||||
char d1[100] = TEST_DESTINATION;
|
||||
char*r1;
|
||||
char s2[100] = TEST_SOURCE;
|
||||
char d2[100] = TEST_DESTINATION;
|
||||
char*r2;
|
||||
char s3[100] = TEST_SOURCE;
|
||||
char d3[100] = TEST_DESTINATION;
|
||||
char*r3;
|
||||
char s4[100] = TEST_SOURCE;
|
||||
char d4[100] = TEST_DESTINATION;
|
||||
char*r4;
|
||||
|
||||
char s1[100] = TEST_SOURCE;
|
||||
char d1[100] = TEST_DESTINATION;
|
||||
char *r1;
|
||||
char s2[100] = TEST_SOURCE;
|
||||
char d2[100] = TEST_DESTINATION;
|
||||
char *r2;
|
||||
char s3[100] = TEST_SOURCE;
|
||||
char d3[100] = TEST_DESTINATION;
|
||||
char *r3;
|
||||
char s4[100] = TEST_SOURCE;
|
||||
char d4[100] = TEST_DESTINATION;
|
||||
char *r4;
|
||||
|
||||
printf("initial strings:\n");
|
||||
dump(s1, TEST_SOURCE_LENGHT);
|
||||
dump(d1, TEST_DESTINATION_LENGHT);
|
||||
r1 = strncpy(d1 ,s1, 4);
|
||||
r1 = strncpy(d1 , s1, 4);
|
||||
printf("strncpy(d, s, 4):\n");
|
||||
dump(s1, TEST_SOURCE_LENGHT);
|
||||
dump(d1, TEST_DESTINATION_LENGHT);
|
||||
@ -28,7 +39,7 @@ int main(void)
|
||||
dump(s2, TEST_SOURCE_LENGHT);
|
||||
dump(d2, TEST_DESTINATION_LENGHT);
|
||||
printf("buffers comparison: s:%i d:%i\n", bufcmp(s1, s2, TEST_SOURCE_LENGHT), bufcmp(d1, d2, TEST_DESTINATION_LENGHT));
|
||||
r3 = strncpy(d3 ,s3, 20);
|
||||
r3 = strncpy(d3 , s3, 20);
|
||||
printf("strncpy(d, s, 20):\n");
|
||||
dump(s3, TEST_SOURCE_LENGHT);
|
||||
dump(d3, TEST_DESTINATION_LENGHT);
|
||||
|
9
c02/ex02.c
Normal file
9
c02/ex02.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
int ft_str_is_alpha(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%i\n", ft_str_is_alpha(argv[1]));
|
||||
}
|
9
c02/ex03.c
Normal file
9
c02/ex03.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
int ft_str_is_numeric(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%i\n", ft_str_is_numeric(argv[1]));
|
||||
}
|
9
c02/ex04.c
Normal file
9
c02/ex04.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
int ft_str_is_lowercase(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%i\n", ft_str_is_lowercase(argv[1]));
|
||||
}
|
9
c02/ex05.c
Normal file
9
c02/ex05.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
int ft_str_is_uppercase(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%i\n", ft_str_is_uppercase(argv[1]));
|
||||
}
|
9
c02/ex06.c
Normal file
9
c02/ex06.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
int ft_str_is_printable(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%i\n", ft_str_is_printable(argv[1]));
|
||||
}
|
9
c02/ex07.c
Normal file
9
c02/ex07.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
char *ft_strupcase(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%s\n", ft_strupcase(argv[1]));
|
||||
}
|
9
c02/ex08.c
Normal file
9
c02/ex08.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
char *ft_strlowcase(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%s\n", ft_strlowcase(argv[1]));
|
||||
}
|
9
c02/ex09.c
Normal file
9
c02/ex09.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <tests.h>
|
||||
|
||||
char *ft_strcapitalize(char *str);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2)
|
||||
printf("%s\n", ft_strcapitalize(argv[1]));
|
||||
}
|
84
c02/ex10.c
Normal file
84
c02/ex10.c
Normal file
@ -0,0 +1,84 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex10.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: achubuko <achubuko@student.42yerevan.am> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/28 01:25:43 by achubuko #+# #+# */
|
||||
/* Updated: 2023/11/28 01:26:11 by achubuko ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <tests.h>
|
||||
#include <stdlib.h>
|
||||
#define TEST_BUF_SIZE 100
|
||||
|
||||
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[TEST_BUF_SIZE] = TEST_SOURCE;
|
||||
char d[TEST_BUF_SIZE] = TEST_DESTINATION;
|
||||
size_t r1;
|
||||
char s1[TEST_BUF_SIZE] = TEST_SOURCE;
|
||||
char d1[TEST_BUF_SIZE] = TEST_DESTINATION;
|
||||
size_t r2;
|
||||
char s2[TEST_BUF_SIZE] = TEST_SOURCE;
|
||||
char d2[TEST_BUF_SIZE] = TEST_DESTINATION;
|
||||
|
||||
printf("initial strings:\n");
|
||||
dump(s, TEST_SOURCE_LENGHT);
|
||||
dump(d, TEST_DESTINATION_LENGHT);
|
||||
|
||||
printf("strlcpy(d, s, 4):\n");
|
||||
r1 = strlcpy(d1, s1, 4);
|
||||
dump(s1, TEST_SOURCE_LENGHT);
|
||||
dump(d1, TEST_DESTINATION_LENGHT);
|
||||
printf("ft_strlcpy(d, s, 4:\n");
|
||||
r2 = ft_strlcpy(d2, s2, 4);
|
||||
dump(s2, TEST_SOURCE_LENGHT);
|
||||
dump(d2, TEST_DESTINATION_LENGHT);
|
||||
printf("buffers comparison: s:%i d:%i\n",
|
||||
bufcmp(s1, s2, TEST_SOURCE_LENGHT),
|
||||
bufcmp(d1, d2, TEST_DESTINATION_LENGHT));
|
||||
printf("return values: orig: %lu ft: %lu\n", r1, r2);
|
||||
memcpy(d1, d, TEST_BUF_SIZE);
|
||||
memcpy(s1, s, TEST_BUF_SIZE);
|
||||
memcpy(d2, d, TEST_BUF_SIZE);
|
||||
memcpy(s2, s, TEST_BUF_SIZE);
|
||||
|
||||
printf("strlcpy(d, s, 20):\n");
|
||||
r1 = strlcpy(d1, s1, 20);
|
||||
dump(s1, TEST_SOURCE_LENGHT);
|
||||
dump(d1, TEST_DESTINATION_LENGHT);
|
||||
printf("ft_strlcpy(d, s, 20):\n");
|
||||
r2 = ft_strlcpy(d2, s2, 20);
|
||||
dump(s2, TEST_SOURCE_LENGHT);
|
||||
dump(d2, TEST_DESTINATION_LENGHT);
|
||||
memcpy(d1, d, TEST_BUF_SIZE);
|
||||
memcpy(s1, s, TEST_BUF_SIZE);
|
||||
memcpy(d2, d, TEST_BUF_SIZE);
|
||||
memcpy(s2, s, TEST_BUF_SIZE);
|
||||
printf("buffers comparison: s:%i d:%i\n",
|
||||
bufcmp(s1, s2, TEST_SOURCE_LENGHT),
|
||||
bufcmp(d1, d2, TEST_DESTINATION_LENGHT));
|
||||
printf("return values: orig: %lu ft: %lu\n", r1, r2);
|
||||
|
||||
printf("strlcpy(s, d, 20):\n");
|
||||
r1 = strlcpy(s1, d1, 20);
|
||||
dump(s1, TEST_SOURCE_LENGHT);
|
||||
dump(d1, TEST_DESTINATION_LENGHT);
|
||||
printf("ft_strlcpy(s, d, 20):\n");
|
||||
r2 = ft_strlcpy(s2, d2, 20);
|
||||
dump(s2, TEST_SOURCE_LENGHT);
|
||||
dump(d2, TEST_DESTINATION_LENGHT);
|
||||
memcpy(d1, d, TEST_BUF_SIZE);
|
||||
memcpy(s1, s, TEST_BUF_SIZE);
|
||||
memcpy(d2, d, TEST_BUF_SIZE);
|
||||
memcpy(s2, s, TEST_BUF_SIZE);
|
||||
printf("buffers comparison: s:%i d:%i\n",
|
||||
bufcmp(s1, s2, TEST_SOURCE_LENGHT),
|
||||
bufcmp(d1, d2, TEST_DESTINATION_LENGHT));
|
||||
printf("return values: orig: %lu ft: %lu\n", r1, r2);
|
||||
}
|
@ -10,5 +10,6 @@
|
||||
#define FG_MAG "\x1B[35m"
|
||||
#define COLOR_RESET "\x1B[0m"
|
||||
#endif
|
||||
int bufcmp(char *this, char *other, int len);
|
||||
void dump(char *data, int len);
|
||||
|
||||
int bufcmp(char*, char*, int);
|
||||
void dump(char*, int);
|
||||
|
Loading…
Reference in New Issue
Block a user