├── .normignore ├── tests ├── libft │ └── fsoares │ │ ├── fsoares │ │ ├── test_isalpha.c │ │ ├── test_isalnum.c │ │ ├── test_isascii.c │ │ ├── test_isdigit.c │ │ ├── test_isprint.c │ │ ├── test_tolower.c │ │ ├── test_toupper.c │ │ ├── my_utils.c │ │ ├── utils │ │ └── color.h │ │ ├── test_strdup.c │ │ ├── test_bzero.c │ │ ├── test_strjoin.c │ │ ├── list_utils.h │ │ ├── test_strlen.c │ │ ├── test_lstsize.c │ │ ├── test_lstlast.c │ │ ├── test_itoa.c │ │ ├── test_strchr.c │ │ ├── test_strmapi.c │ │ ├── test_calloc.c │ │ ├── test_strrchr.c │ │ ├── test_memchr.c │ │ ├── test_strtrim.c │ │ ├── test_lstnew.c │ │ ├── test_strlcpy.c │ │ ├── test_lstiter.c │ │ ├── test_memcpy.c │ │ ├── test_strlcat.c │ │ ├── test_striteri.c │ │ ├── test_lstadd_back.c │ │ ├── test_putchar_fd.c │ │ ├── test_memmove.c │ │ ├── test_putstr_fd.c │ │ ├── test_putendl_fd.c │ │ ├── test_putnbr_fd.c │ │ ├── test_memset.c │ │ ├── test_memcmp.c │ │ ├── test_lstclear.c │ │ ├── test_atoi.c │ │ ├── test_lstdelone.c │ │ ├── test_substr.c │ │ ├── test_strncmp.c │ │ ├── test_lstmap.c │ │ ├── test_lstadd_front.c │ │ ├── test_strnstr.c │ │ └── test_split.c ├── pipex │ └── fsoares │ │ ├── dummy │ │ ├── no_r_perm │ │ ├── outfile.txt │ │ ├── no_w_perm │ │ ├── heredoc.sh │ │ ├── uname │ │ ├── script space.sh │ │ ├── script"quote.sh │ │ ├── no_x_script.sh │ │ ├── infile.txt │ │ ├── script.sh │ │ ├── subdir │ │ └── script.sh │ │ └── middle_fail.sh ├── cpiscine │ ├── c00 │ │ ├── ex04 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex03 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex01 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex07 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex05 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex06 │ │ │ └── main.c │ │ ├── ex00 │ │ │ └── main.c │ │ ├── ex02 │ │ │ └── main.c │ │ └── ex08 │ │ │ └── main.c │ ├── c01 │ │ ├── ex06 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex00 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex01 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex04 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex02 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex05 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex03 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex07 │ │ │ ├── expected │ │ │ └── main.c │ │ └── ex08 │ │ │ ├── expected │ │ │ └── main.c │ ├── c02 │ │ ├── ex00 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex01 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex02 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex03 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex07 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex05 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex04 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex08 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex09 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex10 │ │ │ └── expected │ │ ├── ex06 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex11 │ │ │ ├── expected │ │ │ └── main.c │ │ └── ex12 │ │ │ └── main.c │ ├── c04 │ │ ├── ex01 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex02 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex00 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex03 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex04 │ │ │ ├── expected │ │ │ └── main.c │ │ └── ex05 │ │ │ ├── expected │ │ │ └── main.c │ ├── c05 │ │ ├── ex00 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex01 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex02 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex03 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex05 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex04 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex06 │ │ │ ├── expected │ │ │ └── main.c │ │ ├── ex07 │ │ │ ├── expected │ │ │ └── main.c │ │ └── ex08 │ │ │ └── main.c │ └── c03 │ │ ├── ex00 │ │ ├── expected │ │ └── main.c │ │ ├── ex02 │ │ ├── expected │ │ └── main.c │ │ ├── ex01 │ │ ├── expected │ │ └── main.c │ │ ├── ex03 │ │ ├── expected │ │ └── main.c │ │ ├── ex04 │ │ ├── expected │ │ └── main.c │ │ └── ex05 │ │ └── expected ├── get_next_line │ └── fsoares │ │ ├── 1char.txt │ │ ├── empty.txt │ │ ├── only_nl.txt │ │ ├── multiple_nl.txt │ │ ├── one_line_no_nl.txt │ │ ├── read_error.txt │ │ ├── lines_around_10.txt │ │ ├── variable_nls.txt │ │ ├── utils │ │ └── color.h │ │ ├── file_utils.h │ │ └── Makefile ├── printf │ └── fsoares │ │ ├── bonus.c │ │ ├── utils │ │ └── color.h │ │ └── Makefile ├── utils │ └── color.h └── minitalk │ └── fsoares │ ├── Makefile │ └── middleman.c ├── utils ├── version.py ├── TerminalColors.py ├── update.sh ├── ExecutionContext.py ├── LeaksCheck.py └── update.py ├── doc ├── example.png └── fsoares-.zsh-theme ├── requirements.txt ├── pyproject.toml ├── tester.sh ├── .vscode ├── c_cpp_properties.json ├── launch.json ├── tasks.json └── settings.json ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── bin ├── sync_utils.sh ├── update.sh ├── install.sh └── clean_cache.sh ├── testers ├── pipex │ ├── Pipex.py │ ├── Vfurname.py │ └── Medic.py ├── printf │ ├── Cacharle.py │ ├── Printf.py │ └── UnitTest.py ├── cpiscine │ ├── C03Tester.py │ ├── C04Tester.py │ ├── C01Tester.py │ ├── C00Tester.py │ ├── C05Tester.py │ ├── CPiscine.py │ └── C02Tester.py ├── libft │ ├── BaseExecutor.py │ ├── Libft.py │ └── Alelievr.py ├── get_next_line │ ├── GetNextLine.py │ ├── Tripouille.py │ └── Fsoares.py └── minitalk │ └── Minitalk.py ├── LICENSE ├── .gitmodules └── .gitignore /.normignore: -------------------------------------------------------------------------------- 1 | tests/ 2 | temp/ -------------------------------------------------------------------------------- /tests/libft/fsoares/fsoares: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/dummy: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex04/expected: -------------------------------------------------------------------------------- 1 | PPN -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex06/expected: -------------------------------------------------------------------------------- 1 | 6 0 -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/1char.txt: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/empty.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /utils/version.py: -------------------------------------------------------------------------------- 1 | version = "0.9.15" 2 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/only_nl.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex03/expected: -------------------------------------------------------------------------------- 1 | 01234567890123456789 -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex00/expected: -------------------------------------------------------------------------------- 1 | 42$ 2 | 234$ 3 | 42 -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex01/expected: -------------------------------------------------------------------------------- 1 | 42$ 2 | 234$ 3 | 42 -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex04/expected: -------------------------------------------------------------------------------- 1 | 12 3$ 2 | -8 -3$ 3 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex00/expected: -------------------------------------------------------------------------------- 1 | 1$ 2 | 1$ 3 | 1$ 4 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex01/expected: -------------------------------------------------------------------------------- 1 | 1$ 2 | 1$ 3 | 1$ 4 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/no_r_perm: -------------------------------------------------------------------------------- 1 | you should not read this -------------------------------------------------------------------------------- /tests/pipex/fsoares/outfile.txt: -------------------------------------------------------------------------------- 1 | has some stuff here -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex02/expected: -------------------------------------------------------------------------------- 1 | 23 13$ 2 | 45 -23$ 3 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex05/expected: -------------------------------------------------------------------------------- 1 | hello$ 2 | holla$ 3 | outro -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex01/expected: -------------------------------------------------------------------------------- 1 | --$ 2 | hola!$ 3 | asd^Ksfg -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex03/expected: -------------------------------------------------------------------------------- 1 | 123 10 12 3$ 2 | -123 15 -8 -3$ 3 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/multiple_nl.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/one_line_no_nl.txt: -------------------------------------------------------------------------------- 1 | abcdefghijklmnopqrstuvwxyz -------------------------------------------------------------------------------- /tests/pipex/fsoares/no_w_perm: -------------------------------------------------------------------------------- 1 | you should not be able to write to this 2 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex02/expected: -------------------------------------------------------------------------------- 1 | "abc": 1$ 2 | "": 1$ 3 | "abcdasda1d": 0$ 4 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex03/expected: -------------------------------------------------------------------------------- 1 | "123": 1$ 2 | "": 1$ 3 | "1234567a89": 0$ 4 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/heredoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #command 4 | #input_text -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex01/expected: -------------------------------------------------------------------------------- 1 | abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz -------------------------------------------------------------------------------- /doc/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xicodomingues/francinette/HEAD/doc/example.png -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex07/expected: -------------------------------------------------------------------------------- 1 | 10$ 2 | -1$ 3 | 0$ 4 | -123$ 5 | 2147483647$ 6 | -2147483648 -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex02/expected: -------------------------------------------------------------------------------- 1 | 0$ 2 | 10$ 3 | -10$ 4 | 2147483647$ 5 | -2147483648$ 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | GitPython 2 | halo 3 | pexpect 4 | rich 5 | toml 6 | certifi 7 | packaging 8 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex07/expected: -------------------------------------------------------------------------------- 1 | $ 2 | 10 9 8 7 6 5 4 3 2 1 $ 3 | 11 10 9 8 7 6 5 4 3 2 1 $ 4 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex00/expected: -------------------------------------------------------------------------------- 1 | 0:0$ 2 | 0:0$ 3 | 1:1$ 4 | 1:1$ 5 | 3628800:3628800$ 6 | 6:6$ 7 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex01/expected: -------------------------------------------------------------------------------- 1 | 0:0$ 2 | 0:0$ 3 | 1:1$ 4 | 1:1$ 5 | 3628800:3628800$ 6 | 6:6$ 7 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex02/expected: -------------------------------------------------------------------------------- 1 | 0:0$ 2 | 0:0$ 3 | 1:1$ 4 | 10:10$ 5 | 100:100$ 6 | 216:216$ 7 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex03/expected: -------------------------------------------------------------------------------- 1 | 0:0$ 2 | 0:0$ 3 | 1:1$ 4 | 10:10$ 5 | 100:100$ 6 | 216:216$ 7 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/uname: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | printf "This is not the real uname! Check the path!" -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex07/expected: -------------------------------------------------------------------------------- 1 | "abcd-fsdAfddsSS": ABCD-FSDAFDDSSS$ 2 | Same string returned? 1$ 3 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/read_error.txt: -------------------------------------------------------------------------------- 1 | aaaaaaaaaa 2 | bbbbbbbbbb 3 | cccccccccc 4 | dddddddddd 5 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/script space.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "A script that has a space in the name" -------------------------------------------------------------------------------- /tests/pipex/fsoares/script"quote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "A script that has a quote in the name" -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex05/expected: -------------------------------------------------------------------------------- 1 | "ABZ": 1$ 2 | "AB@": 0$ 3 | "AB[": 0$ 4 | "": 1$ 5 | "DASFJET..": 0$ 6 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex00/expected: -------------------------------------------------------------------------------- 1 | len of: '': 0$ 2 | len of: 'sggdsdsg': 8$ 3 | len of: 'asd^Ksfg': 7$ 4 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex03/expected: -------------------------------------------------------------------------------- 1 | 23$ 2 | -12341$ 3 | -123413$ 4 | 2147483647$ 5 | -2147483648$ 6 | 0$ 7 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex05/expected: -------------------------------------------------------------------------------- 1 | 10:10$ 2 | 6:6$ 3 | 0:0$ 4 | 100:100$ 5 | 0:0$ 6 | 2000:2000$ 7 | 0:0$ 8 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex04/expected: -------------------------------------------------------------------------------- 1 | -1:-1$ 2 | -1:-1$ 3 | 0:0$ 4 | 1:1$ 5 | 1:1$ 6 | 2:2$ 7 | 55:55$ 8 | 6765:6765$ 9 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/lines_around_10.txt: -------------------------------------------------------------------------------- 1 | 0123456789 2 | 012345678 3 | 90123456789 4 | 0123456789 5 | xxxx 6 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex04/expected: -------------------------------------------------------------------------------- 1 | "abz": 1$ 2 | "ab{": 0$ 3 | "ab`": 0$ 4 | "": 1$ 5 | "asdasda..": 0$ 6 | "asdasAa": 0$ 7 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex08/expected: -------------------------------------------------------------------------------- 1 | "ABDSDF-sdfsdf,,sdfYU74rff;": abdsdf-sdfsdf,,sdfyu74rff;$ 2 | Same string returned? 1$ 3 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/no_x_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #You should not be able to execute this script 4 | ls -la "$HOME" -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex09/expected: -------------------------------------------------------------------------------- 1 | Salut, Comment Tu Vas ? 42mots Quarante-Deux; Cinquante+Et+Un E.Puntos$ 2 | Same string returned? 1$ 3 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex00/expected: -------------------------------------------------------------------------------- 1 | std: -97, yours: -97$ 2 | std: 0, yours: 0$ 3 | std: 101, yours: 101$ 4 | std: -116, yours: -116$ 5 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex02/expected: -------------------------------------------------------------------------------- 1 | same string: yours: 'aaaaxyz', std: 'aaaaxyz', 1$ 2 | same string: yours: 'aaaa', std: 'aaaa': 1$ 3 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/infile.txt: -------------------------------------------------------------------------------- 1 | Teste file with stuff inside 2 | That does nothing 3 | And also have some lines 4 | And some more information -------------------------------------------------------------------------------- /tests/pipex/fsoares/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #read from stdin 4 | while read line 5 | do 6 | echo "$line" 7 | done 8 | 9 | echo "Some more text" -------------------------------------------------------------------------------- /tests/pipex/fsoares/subdir/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #read from stdin 4 | while read line 5 | do 6 | echo "$line" 7 | done 8 | 9 | echo "Some more text" -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex06/expected: -------------------------------------------------------------------------------- 1 | OK$ 2 | OK$ 3 | OK$ 4 | OK$ 5 | OK$ 6 | OK$ 7 | OK$ 8 | OK$ 9 | OK$ 10 | OK$ 11 | OK$ 12 | OK$ 13 | OK$ 14 | OK$ 15 | OK$ 16 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex07/expected: -------------------------------------------------------------------------------- 1 | OK$ 2 | OK$ 3 | OK$ 4 | OK$ 5 | OK$ 6 | OK$ 7 | OK$ 8 | OK$ 9 | OK$ 10 | OK$ 11 | OK$ 12 | OK$ 13 | OK$ 14 | OK$ 15 | OK$ 16 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.commitizen] 2 | name = "cz_conventional_commits" 3 | version = "0.9.15" 4 | version_files = [ "utils/version.py",] 5 | changelog_file = "doc/CHANGELOG.md" 6 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_isalpha.c: -------------------------------------------------------------------------------- 1 | #include "my_utils.h" 2 | 3 | create_test_ctype(isalpha); 4 | 5 | int main() 6 | { 7 | handle_signals_with_time(); 8 | test(isalpha); 9 | } 10 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_isalnum.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_ctype(isalnum); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(isalnum); 10 | } 11 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_isascii.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_ctype(isascii); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(isascii); 10 | } 11 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_isdigit.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_ctype(isdigit); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(isdigit); 10 | } 11 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_isprint.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_ctype(isprint); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(isprint); 10 | } 11 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_tolower.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_val(tolower); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(tolower); 10 | } 11 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_toupper.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | create_test_val(toupper); 5 | 6 | int main() 7 | { 8 | handle_signals_with_time(); 9 | test(toupper); 10 | } 11 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex01/expected: -------------------------------------------------------------------------------- 1 | std: -1, yours: -1$ 2 | std: 0, yours: 0$ 3 | std: -1, yours: -1$ 4 | std: 0, yours: 0$ 5 | std: 101, yours: 101$ 6 | std: 0, yours: 0$ 7 | std: -116, yours: -116$ 8 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex10/expected: -------------------------------------------------------------------------------- 1 | std: 4, yours: 4, same string: 1$ 2 | std: 4, yours: 4, same string: 1$ 3 | std: 7, yours: 7, same string: 1$ 4 | std: 2, yours: 2, same string: 1$ 5 | std: 6, yours: 6, same string: 1$ 6 | -------------------------------------------------------------------------------- /tests/pipex/fsoares/middle_fail.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #read from stdin 4 | while read line 5 | do 6 | echo "$line" 7 | done 8 | 9 | echo "some other stuff" 10 | echo "show some dummy error message" 1>&2 11 | 12 | exit 13 -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex04/expected: -------------------------------------------------------------------------------- 1 | 42:42$ 2 | 2a:2a$ 3 | -2a:-2a$ 4 | 0:0$ 5 | INT_MAX:7fffffff$ 6 | INT_MAX:XEFnoY$ 7 | INT_MIN:-80000000$ 8 | -2143247366 : -~~~~~~~~'~~~~~~'~'~~~'''''''~~'$ 9 | -1:-1$ 10 | :$ 11 | :$ 12 | :$ 13 | : -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex06/expected: -------------------------------------------------------------------------------- 1 | "": 1$ 2 | " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~": 1$ 3 | with a tab: 0$ 4 | With the character just before: 0$ 5 | With the character just after: 0$ 6 | -------------------------------------------------------------------------------- /tester.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 3 | 4 | current_dir=$PWD 5 | 6 | # check for updates 7 | version=68 8 | 9 | cd "$current_dir" || exit 10 | source "$DIR"/venv/bin/activate 11 | 12 | python "$DIR"/main.py "$@" 13 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex05/expected: -------------------------------------------------------------------------------- 1 | 42:42$ 2 | -42:-42$ 3 | 42:42$ 4 | 0:0$ 5 | 0:0$ 6 | 0:0$ 7 | 0:0$ 8 | 0:0$ 9 | 0:0$ 10 | 2147483647 : 2147483647 (equals: 1)$ 11 | -2147483648 : -2147483648 (equals: 1)$ 12 | 2147483647 : 2147483647 (equals: 1)$ 13 | -2143247366 : -2143247366 (equals: 1)$ 14 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/variable_nls.txt: -------------------------------------------------------------------------------- 1 | 2 | 0123456789012345678901234567890123456789x2 3 | 0123456789012345678901234567890123456789x3 4 | 5 | 0123456789012345678901234567890123456789x5 6 | 7 | 8 | 0123456789012345678901234567890123456789x8 9 | 10 | 11 | 12 | 0123456789012345678901234567890123456789x12 -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex03/expected: -------------------------------------------------------------------------------- 1 | n: 0, same string: yours: 'aaaa', std: 'aaaa', 1$ 2 | n: 2, same string: yours: 'aaaaxy', std: 'aaaaxy', 1$ 3 | n: 3, same string: yours: 'aaaaxyz', std: 'aaaaxyz', 1$ 4 | n: 4, same string: yours: 'aaaaxyz', std: 'aaaaxyz', 1$ 5 | n: 5, same string: yours: 'aaaaxyz', std: 'aaaaxyz', 1$ 6 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex04/expected: -------------------------------------------------------------------------------- 1 | return the same positon: 1 (yours: '0', std: '0')$ 2 | return the same positon: 1 (yours: '2', std: '2')$ 3 | return NULL on no match: 1, 1$ 4 | return the first position on empty string: 1 (yours: '0', std: '0')$ 5 | return same position on both empty strings: 1$ 6 | return NULL if src is empty: 1 (yours: '0x0', std: '0x0')$ 7 | -------------------------------------------------------------------------------- /tests/printf/fsoares/bonus.c: -------------------------------------------------------------------------------- 1 | #include "pf_utils.h" 2 | 3 | // generated in python 4 | //==%%^^&&++== 5 | 6 | int main(int argn, char **argv) 7 | { 8 | printf(YEL "\nBonus:" NC "\n"); 9 | pf_setup_framework(argn, argv); 10 | 11 | test_c(); 12 | test_s(); 13 | test_p(); 14 | test_d(); 15 | test_i(); 16 | test_u(); 17 | test_x(); 18 | test_X(); 19 | test_percent(); 20 | } -------------------------------------------------------------------------------- /utils/TerminalColors.py: -------------------------------------------------------------------------------- 1 | 2 | class TC: 3 | B_WHITE = '\033[1;37m' 4 | RED = '\033[0;31m' 5 | GREEN = '\033[0;32m' 6 | CYAN = '\033[0;36m' 7 | B_CYAN = '\033[1;36m' 8 | B_GREEN = '\033[1;32m' 9 | B_BLUE = '\033[1;34m' 10 | BLUE = '\033[0;34m' 11 | PURPLE = '\033[0;35m' 12 | B_PURPLE = '\033[1;35m' 13 | YELLOW = '\033[0;33m' 14 | B_YELLOW = '\033[1;33m' 15 | B_RED = '\033[1;31m' 16 | NC = '\033[0m' # No Color 17 | -------------------------------------------------------------------------------- /tests/libft/fsoares/my_utils.c: -------------------------------------------------------------------------------- 1 | #include "my_utils.h" 2 | 3 | void handle_signals_with_time() 4 | { 5 | alarm(TIMEOUT); 6 | handle_signals(); 7 | } 8 | 9 | int set_signature_tn(int test_number, const char *format, ...) 10 | { 11 | g_test = test_number; 12 | va_list args; 13 | va_start(args, format); 14 | g_offset = vsprintf(signature, format, args); 15 | va_end(args); 16 | reset_malloc_mock(); 17 | return g_offset; 18 | } 19 | -------------------------------------------------------------------------------- /tests/utils/color.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_H_ 2 | #define COLOR_H_ 3 | 4 | #define BRED "\x1B[1;31m" 5 | #define RED "\x1B[0;31m" 6 | #define BGRN "\x1B[1;32m" 7 | #define GRN "\x1B[0;32m" 8 | #define YEL "\x1B[0;33m" 9 | #define BLU "\x1B[0;34m" 10 | #define BMAG "\x1B[1;35m" 11 | #define MAG "\x1B[0;35m" 12 | #define CYN "\x1B[0;36m" 13 | #define BCYN "\x1B[1;36m" 14 | #define BWHT "\x1B[1;37m" 15 | #define NC "\x1B[0m" 16 | 17 | #endif -------------------------------------------------------------------------------- /tests/libft/fsoares/utils/color.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_H_ 2 | #define COLOR_H_ 3 | 4 | #define BRED "\x1B[1;31m" 5 | #define RED "\x1B[0;31m" 6 | #define BGRN "\x1B[1;32m" 7 | #define GRN "\x1B[0;32m" 8 | #define YEL "\x1B[0;33m" 9 | #define BLU "\x1B[0;34m" 10 | #define BMAG "\x1B[1;35m" 11 | #define MAG "\x1B[0;35m" 12 | #define CYN "\x1B[0;36m" 13 | #define BCYN "\x1B[1;36m" 14 | #define BWHT "\x1B[1;37m" 15 | #define NC "\x1B[0m" 16 | 17 | #endif -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex08/expected: -------------------------------------------------------------------------------- 1 | $ 2 | 1 2 3 4 5 6 7 8 9 10 $ 3 | 1 2 3 4 5 6 7 8 9 10 11 $ 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 $ 5 | -------------------------------------------------------------------------------- /tests/printf/fsoares/utils/color.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_H_ 2 | #define COLOR_H_ 3 | 4 | #define BRED "\x1B[1;31m" 5 | #define RED "\x1B[0;31m" 6 | #define BGRN "\x1B[1;32m" 7 | #define GRN "\x1B[0;32m" 8 | #define YEL "\x1B[0;33m" 9 | #define BLU "\x1B[0;34m" 10 | #define BMAG "\x1B[1;35m" 11 | #define MAG "\x1B[0;35m" 12 | #define CYN "\x1B[0;36m" 13 | #define BCYN "\x1B[1;36m" 14 | #define BWHT "\x1B[1;37m" 15 | #define NC "\x1B[0m" 16 | 17 | #endif -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/utils/color.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_H_ 2 | #define COLOR_H_ 3 | 4 | #define BRED "\x1B[1;31m" 5 | #define RED "\x1B[0;31m" 6 | #define BGRN "\x1B[1;32m" 7 | #define GRN "\x1B[0;32m" 8 | #define YEL "\x1B[0;33m" 9 | #define BLU "\x1B[0;34m" 10 | #define BMAG "\x1B[1;35m" 11 | #define MAG "\x1B[0;35m" 12 | #define CYN "\x1B[0;36m" 13 | #define BCYN "\x1B[1;36m" 14 | #define BWHT "\x1B[1;37m" 15 | #define NC "\x1B[0m" 16 | 17 | #endif -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex05/expected: -------------------------------------------------------------------------------- 1 | n: 0, same string: yours: 'aaaa':3, std: 'aaaa':3, 1$ 2 | n: 2, same string: yours: 'aaaa':5, std: 'aaaa':5, 1$ 3 | n: 3, same string: yours: 'aaaa':6, std: 'aaaa':6, 1$ 4 | n: 4, same string: yours: 'aaaa':7, std: 'aaaa':7, 1$ 5 | n: 5, same string: yours: 'aaaa':7, std: 'aaaa':7, 1$ 6 | n: 6, same string: yours: 'aaaax':7, std: 'aaaax':7, 1$ 7 | n: 20, same string: yours: 'aaaaxyz':7, std: 'aaaaxyz':7, 1$ 8 | n: 2, same string: yours: 'aaaaaaa':18, std: 'aaaaaaa':18, 1$ 9 | -------------------------------------------------------------------------------- /tests/minitalk/fsoares/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | @gcc middleman.c -o middleman.out 4 | @make -s -C ../__my_srcs all > /dev/null 5 | 6 | bonus: 7 | @gcc middleman.c -o middleman.out 8 | @make -s -C ../__my_srcs bonus > /dev/null 9 | @if [ -f ../__my_srcs/client_bonus ]; then mv ../__my_srcs/client_bonus ../__my_srcs/client; fi; 10 | @if [ -f ../__my_srcs/server_bonus ]; then mv ../__my_srcs/server_bonus ../__my_srcs/server; fi; 11 | 12 | fclean: 13 | @make -s -C ../__my_srcs fclean > /dev/null 14 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [], 9 | "macFrameworkPath": [ 10 | "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks" 11 | ], 12 | "compilerPath": "/usr/bin/clang", 13 | "cStandard": "c11", 14 | "cppStandard": "c++98" 15 | } 16 | ], 17 | "version": 4 18 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug with Francinette 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | Please include a description of the problem as well has what operation system you are using 12 | - OS: [e.g. MacOS Catalina, Ubuntu 20.04, ...] 13 | - The architecture of the CPU if it is not x64 (for example ARM Macs (M1, M2)) 14 | 15 | **Additional information** 16 | If you think it could be relevant, please include the file that is under `~/francinette/logs/execution.log` 17 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex05/expected: -------------------------------------------------------------------------------- 1 | 012, 013, 014, 015, 016, 017, 018, 019, 023, 024, 025, 026, 027, 028, 029, 034, 035, 036, 037, 038, 039, 045, 046, 047, 048, 049, 056, 057, 058, 059, 067, 068, 069, 078, 079, 089, 123, 124, 125, 126, 127, 128, 129, 134, 135, 136, 137, 138, 139, 145, 146, 147, 148, 149, 156, 157, 158, 159, 167, 168, 169, 178, 179, 189, 234, 235, 236, 237, 238, 239, 245, 246, 247, 248, 249, 256, 257, 258, 259, 267, 268, 269, 278, 279, 289, 345, 346, 347, 348, 349, 356, 357, 358, 359, 367, 368, 369, 378, 379, 389, 456, 457, 458, 459, 467, 468, 469, 478, 479, 489, 567, 568, 569, 578, 579, 589, 678, 679, 689, 789 -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex11/expected: -------------------------------------------------------------------------------- 1 | Coucou\0atu vas bien ?$ 2 | \01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\7f\80\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97\98\99\9a\9b\9c\9d\9e\9f\a0\a1\a2\a3\a4\a5\a6\a7\a8\a9\aa\ab\ac\ad\ae\af\b0\b1\b2\b3\b4\b5\b6\b7\b8\b9\ba\bb\bc\bd\be\bf\c0\c1\c2\c3\c4\c5\c6\c7\c8\c9\ca\cb\cc\cd\ce\cf\d0\d1\d2\d3\d4\d5\d6\d7\d8\d9\da\db\dc\dd\de\df\e0\e1\e2\e3\e4\e5\e6\e7\e8\e9\ea\eb\ec\ed\ee\ef\f0\f1\f2\f3\f4\f5\f6\f7\f8\f9\fa\fb\fc\fd\fe\ff$ 3 | -------------------------------------------------------------------------------- /bin/sync_utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 | base=$(dirname "$SCRIPT_DIR") 5 | 6 | cd $base || exit 7 | 8 | if [[ $1 == "-f" ]]; then 9 | force=1 10 | fi 11 | 12 | update_utils() 13 | { 14 | DIR=$1 15 | changes=$(git diff --quiet $DIR/utils || printf "changed" ) 16 | if [[ $changes == "changed" && $force -ne 1 ]]; then 17 | echo "$DIR has changes!" 18 | else 19 | cp -r "$base"/tests/utils $DIR 20 | fi 21 | } 22 | 23 | update_utils tests/libft/fsoares 24 | update_utils tests/get_next_line/fsoares 25 | update_utils tests/printf/fsoares 26 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strdup.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strdup(int test_number, char *str, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_strdup(%s)", escape_str(str)); 7 | check_alloc_str_return(ft_strdup(str), expected); 8 | } 9 | 10 | int test_strdup() 11 | { 12 | int res = 1; 13 | res = single_test_strdup(1, "", "") && res; 14 | res = single_test_strdup(2, "sadfvbf", "sadfvbf") && res; 15 | res = single_test_strdup(3, "fdfjkdf\n35346", "fdfjkdf\n35346") && res; 16 | return res; 17 | } 18 | 19 | int main() 20 | { 21 | handle_signals_with_time(); 22 | test(strdup); 23 | } 24 | -------------------------------------------------------------------------------- /testers/pipex/Pipex.py: -------------------------------------------------------------------------------- 1 | from testers.BaseTester import BaseTester 2 | from testers.pipex.Fsoares import Fsoares 3 | from testers.pipex.Medic import Medic 4 | from testers.pipex.Vfurname import Vfurname 5 | from utils.ExecutionContext import TestRunInfo 6 | from utils.Utils import is_makefile_project 7 | 8 | 9 | class Pipex(BaseTester): 10 | 11 | name = "pipex" 12 | my_tester = Fsoares 13 | testers = [Vfurname, Medic, Fsoares] 14 | timeout = 1 15 | 16 | def __init__(self, info: TestRunInfo) -> None: 17 | super().__init__(info) 18 | self.execute_testers() 19 | pass 20 | 21 | @staticmethod 22 | def is_project(current_path): 23 | return is_makefile_project(current_path, "pipex", Pipex) 24 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_bzero.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_bzero(int test_number, char *res, char *expected, int size) 5 | { 6 | set_signature_tn(test_number, "ft_bzero(%p, %i)", res, size); 7 | reset(res, expected, MEM_SIZE); 8 | bzero(expected, size); 9 | ft_bzero(res, size); 10 | 11 | return (same_mem(expected, res, MEM_SIZE)); 12 | } 13 | 14 | int test_bzero(void) 15 | { 16 | char mem[MEM_SIZE]; 17 | char mem_std[MEM_SIZE]; 18 | 19 | int res = 1; 20 | 21 | res = single_test_bzero(1, mem, mem_std, 0) && res; 22 | res = single_test_bzero(2, mem, mem_std, 12) && res; 23 | 24 | return res; 25 | } 26 | 27 | int main() 28 | { 29 | handle_signals_with_time(); 30 | test(bzero); 31 | } 32 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strjoin.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int test_single_strjoin(int test_number, char *str1, char *str2, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_strjoin(\"%s\", \"%s\")", str1, str2); 7 | check_alloc_str_return(ft_strjoin(str1, str2), expected); 8 | } 9 | 10 | int test_strjoin() 11 | { 12 | int res = 1; 13 | res = test_single_strjoin(1, "", "", "") && res; 14 | res = test_single_strjoin(2, "abc", "", "abc") && res; 15 | res = test_single_strjoin(3, "", "abc", "abc") && res; 16 | res = test_single_strjoin(4, "abcd", "efghi", "abcdefghi") && res; 17 | 18 | return res; 19 | } 20 | 21 | int main() 22 | { 23 | handle_signals_with_time(); 24 | test(strjoin); 25 | } 26 | -------------------------------------------------------------------------------- /tests/libft/fsoares/list_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef LIST_UTILS_H 2 | #define LIST_UTILS_H 3 | 4 | #include "my_utils.h" 5 | 6 | int same_list_elem(t_list *expected, t_list *result); 7 | 8 | t_list *lstnew(void *content); 9 | void lstadd_front(t_list **list, t_list *new); 10 | t_list **create_list(int n_elems, ...); 11 | int same_list(t_list **expected, t_list **result); 12 | int same_list_bool(t_list **expected, t_list **result); 13 | 14 | char *node_to_str(t_list *node); 15 | char *list_to_str(t_list **head_ptr); 16 | char *list_to_str_fn(t_list **head_ptr, char *(*str_node)(t_list *node)); 17 | t_list *lstlast(t_list *lst); 18 | void lstadd_back(t_list **list, t_list *new); 19 | void lstclear(t_list **lst, void (*del)(void *)); 20 | 21 | #endif -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strlen.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int compare_strlen(int test_number, char *str) 5 | { 6 | set_signature_tn(test_number, "ft_strlen(%s)", escape_str(str)); 7 | return same_value(strlen(str), ft_strlen(str)); 8 | } 9 | 10 | int test_strlen(void) 11 | { 12 | char str[100]; 13 | int res = 1; 14 | 15 | res = compare_strlen(1, "") && res; 16 | str[0] = EOF; 17 | str[1] = '\0'; 18 | res = compare_strlen(2, str) && res; 19 | const char *s = "aaaaa"; 20 | ft_strlen(s); 21 | 22 | for (int n = 0; n < REPETITIONS && res; n++) 23 | { 24 | rand_str(str, rand() % 98 + 1); 25 | res = compare_strlen(3 + n, str) && res; 26 | } 27 | return res; 28 | } 29 | 30 | int main() 31 | { 32 | handle_signals_with_time(); 33 | test(strlen); 34 | } 35 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstsize.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | int single_test_lstsize(int test_number, t_list **list, int expected) 5 | { 6 | char *list_str = list_to_str(list); 7 | set_signature_tn(test_number, "ft_lstsize(%s)", list_str); 8 | free(list_str); 9 | 10 | int result = same_value(expected, ft_lstsize(*list)); 11 | null_null_check(ft_lstsize(*list), result); 12 | return result; 13 | } 14 | 15 | int test_lstsize() 16 | { 17 | int res = single_test_lstsize(1, create_list(0), 0); 18 | res = single_test_lstsize(2, create_list(1, "one"), 1) && res; 19 | res = single_test_lstsize(3, 20 | create_list(5, "one", "two", "three", "four", "five"), 21 | 5) && res; 22 | return res; 23 | } 24 | 25 | int main() 26 | { 27 | handle_signals_with_time(); 28 | test(lstsize); 29 | } 30 | -------------------------------------------------------------------------------- /bin/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$(uname)" != "Darwin" ]; then 4 | echo "Admin permissions need to install newer packages" 5 | sudo apt install libbsd-dev libncurses-dev 6 | fi 7 | 8 | cd "$HOME"/francinette || exit 9 | 10 | git fetch origin 11 | git reset --hard origin 12 | git submodule update --init 13 | 14 | # activate venv 15 | . venv/bin/activate 16 | 17 | echo "Updating python dependencies..." 18 | # install requirements 19 | if ! pip3 install --disable-pip-version-check -q -r requirements.txt ; then 20 | echo "Problem updating francinette. Contact me (fsoares- on slack)" 21 | exit 1 22 | fi 23 | 24 | echo -e "\033[1;37mFrancinette is updated. You can use it again!\033[0m" 25 | 26 | printf "\033[33m... but don't forget, \033[1;37mpaco\033[0;33m is not a replacement for your own tests! \033[0m\n" 27 | -------------------------------------------------------------------------------- /testers/printf/Cacharle.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from halo import Halo 4 | from testers.BaseExecutor import BaseExecutor 5 | 6 | logger = logging.getLogger('pf-charle') 7 | 8 | 9 | class Cacharle(BaseExecutor): 10 | 11 | name = 'ft_printf_test' 12 | folder = 'ft_printf_test' 13 | git_url = 'https://github.com/cacharle/ft_printf_test' 14 | 15 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 16 | super().__init__(tests_dir, temp_dir, to_execute, missing) 17 | 18 | def execute(self): 19 | if not self.exec_bonus: 20 | return [] 21 | with Halo(self.get_info_message("Compiling tests")) as spinner: 22 | self.call_make_command('all', self.exec_bonus, True, spinner=spinner) 23 | 24 | output = self.run_tests("make quiet") 25 | return self.result(not output.splitlines()[-2].startswith('=====')) 26 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstlast.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | int single_test_lstlast(int test_number, t_list **list, t_list *expected) 5 | { 6 | char *list_str = list_to_str(list); 7 | set_signature_tn(test_number, "ft_lstlast(%s)", list_str); 8 | free(list_str); 9 | 10 | int result = same_list_elem(expected, ft_lstlast(*list)); 11 | null_null_check(ft_lstlast(*list), result); 12 | return result; 13 | } 14 | 15 | int test_lstlast() 16 | { 17 | int res = single_test_lstlast(1, create_list(0), NULL); 18 | res = single_test_lstlast(2, create_list(1, "one"), lstnew("one")) && res; 19 | res = single_test_lstlast(3, 20 | create_list(5, "one", "two", "three", "four", "five"), 21 | lstnew("five")) && res; 22 | return res; 23 | } 24 | 25 | int main() 26 | { 27 | handle_signals_with_time(); 28 | test(lstlast); 29 | } 30 | -------------------------------------------------------------------------------- /testers/printf/Printf.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from testers.BaseTester import BaseTester 4 | from testers.printf.Cacharle import Cacharle 5 | from testers.printf.Fsoares import Fsoares 6 | from testers.printf.Tripouille import Tripouille 7 | from testers.printf.UnitTest import UnitTest 8 | from utils.ExecutionContext import TestRunInfo 9 | from utils.Utils import is_makefile_project 10 | 11 | logger = logging.getLogger('printf') 12 | 13 | 14 | class Printf(BaseTester): 15 | 16 | name = "printf" 17 | my_tester = Fsoares 18 | testers = [Tripouille, UnitTest, Cacharle, Fsoares] 19 | timeout = 2 20 | 21 | def __init__(self, info: TestRunInfo) -> None: 22 | super().__init__(info) 23 | self.execute_testers() 24 | pass 25 | 26 | @staticmethod 27 | def is_project(current_path): 28 | return is_makefile_project(current_path, "libftprintf.a", Printf) 29 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_itoa.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_itoa(int test_number, char *buffer, int n) 5 | { 6 | set_signature_tn(test_number, "ft_itoa(%i)", n); 7 | sprintf(buffer, "%i", n); 8 | check_alloc_str_return(ft_itoa(n), buffer); 9 | } 10 | 11 | int test_itoa() 12 | { 13 | char buffer[100]; 14 | int res = single_test_itoa(1, buffer, 0); 15 | res = single_test_itoa(2, buffer, 1000034) && res; 16 | res = single_test_itoa(3, buffer, -10004) && res; 17 | res = single_test_itoa(4, buffer, INT_MAX) && res; 18 | res = single_test_itoa(5, buffer, INT_MIN) && res; 19 | for (int i = 0; i < REPETITIONS && res; i++) { 20 | int rd = (int)random() - RAND_MAX / 2; 21 | res = single_test_itoa(6 + i, buffer, rd) && res; 22 | } 23 | return res; 24 | } 25 | 26 | int main() 27 | { 28 | handle_signals_with_time(); 29 | test(itoa); 30 | } 31 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strchr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strchr(int test_number, char *str, int ch) 5 | { 6 | set_signature_tn(test_number, "ft_strchr(%p: \"%s\", %i: %s)", str, str, ch, escape_chr(ch)); 7 | char *res = ft_strchr(str, ch); 8 | char *res_std = strchr(str, ch); 9 | 10 | return same_offset(str, res_std, str, res); 11 | } 12 | 13 | int test_strchr(void) 14 | { 15 | int res = 1; 16 | 17 | res = single_test_strchr(1,"teste", 't') && res; 18 | res = single_test_strchr(2,"teste", 'e') && res; 19 | res = single_test_strchr(3, "teste", '\0') && res; 20 | res = single_test_strchr(4, "teste", 'a') && res; 21 | res = single_test_strchr(5, "teste", 'e' + 256) && res; 22 | res = single_test_strchr(6, "teste", 1024) && res; 23 | 24 | return res; 25 | } 26 | 27 | int main() 28 | { 29 | handle_signals_with_time(); 30 | test(strchr); 31 | } 32 | -------------------------------------------------------------------------------- /tests/printf/fsoares/Makefile: -------------------------------------------------------------------------------- 1 | TIMEOUT = 10 2 | CFLAGS = -g -fsanitize=address -Wall -Wextra -Werror 3 | STRICT = 4 | UTILS = utils/malloc_mock.c utils/utils.c pf_utils.c 5 | PRINTF_LIB = ../__my_srcs/libftprintf.a 6 | TIMEOUT_ARG = -D TIMEOUT=$(TIMEOUT) 7 | 8 | ifdef EXEC_STRICT 9 | STRICT = -D STRICT_MEM 10 | endif 11 | 12 | # SDK headers shipping w/Xcode 14.1 (22/11/01) 13 | # and later deprecate some functions used here 14 | CFLAGS += -Wno-deprecated-declarations 15 | 16 | build_m: 17 | -@$(MAKE) -C ../__my_srcs fclean 1> /dev/null 18 | -@$(MAKE) -s -C ../__my_srcs all 1> /dev/null 19 | -@clang $(CFLAGS) $(TIMEOUT_ARG) $(STRICT) $(UTILS) mandatory.c $(PRINTF_LIB) -ldl -o printf.out 20 | 21 | build_b: 22 | -@$(MAKE) -C ../__my_srcs fclean 1> /dev/null 23 | -@$(MAKE) -s -C ../__my_srcs bonus 1> /dev/null 24 | -@clang $(CFLAGS) $(TIMEOUT_ARG) $(STRICT) $(UTILS) bonus.c $(PRINTF_LIB) -ldl -o printf_b.out -------------------------------------------------------------------------------- /testers/cpiscine/C03Tester.py: -------------------------------------------------------------------------------- 1 | from testers.cpiscine.CommonTester import CommonTester 2 | from utils.ExecutionContext import TestRunInfo 3 | 4 | 5 | class C03Tester(CommonTester): 6 | 7 | name = "c03" 8 | 9 | def __init__(self, info: TestRunInfo): 10 | super().__init__(info) 11 | 12 | def ex00(self): 13 | self.exercise_files = ["ft_strcmp.c"] 14 | self.test_files = ["main.c"] 15 | 16 | def ex01(self): 17 | self.exercise_files = ["ft_strncmp.c"] 18 | self.test_files = ["main.c"] 19 | 20 | def ex02(self): 21 | self.exercise_files = ["ft_strcat.c"] 22 | self.test_files = ["main.c"] 23 | 24 | def ex03(self): 25 | self.exercise_files = ["ft_strncat.c"] 26 | self.test_files = ["main.c"] 27 | 28 | def ex04(self): 29 | self.exercise_files = ["ft_strstr.c"] 30 | self.test_files = ["main.c"] 31 | 32 | def ex05(self): 33 | self.exercise_files = ["ft_strlcat.c"] 34 | self.test_files = ["main.c"] 35 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strmapi.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strmapi(int test_number, char *str, char (*fn)(unsigned int, char), char *func, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_strmapi(\"%s\", %s)", str, func); 7 | check_alloc_str_return(ft_strmapi(str, fn), expected); 8 | } 9 | 10 | char add(unsigned int i, char c) { 11 | return (char)(i + c); 12 | } 13 | 14 | char to_char_zero(unsigned int i, char c) { 15 | c = (char)i; 16 | return '0' + c - c; 17 | } 18 | 19 | int test_strmapi() 20 | { 21 | int res = single_test_strmapi(1, "", add, "{(i, c) => i + c}", ""); 22 | res = single_test_strmapi(2, "abcd0 ", add, "{(i, c) => i + c}", "aceg4%") && res; 23 | res = single_test_strmapi(3, "abcdfsdfs", to_char_zero, "{(i, c) => '0'}", "000000000") && res; 24 | 25 | return res; 26 | } 27 | 28 | int main() 29 | { 30 | handle_signals_with_time(); 31 | test(strmapi); 32 | } 33 | -------------------------------------------------------------------------------- /testers/cpiscine/C04Tester.py: -------------------------------------------------------------------------------- 1 | from testers.cpiscine.CommonTester import CommonTester 2 | from utils.ExecutionContext import TestRunInfo 3 | 4 | 5 | class C04Tester(CommonTester): 6 | 7 | name = "c04" 8 | 9 | def __init__(self, info: TestRunInfo): 10 | super().__init__(info) 11 | 12 | def ex00(self): 13 | self.exercise_files = ["ft_strlen.c"] 14 | self.test_files = ["main.c"] 15 | 16 | def ex01(self): 17 | self.exercise_files = ["ft_putstr.c"] 18 | self.test_files = ["main.c"] 19 | 20 | def ex02(self): 21 | self.exercise_files = ["ft_putnbr.c"] 22 | self.test_files = ["main.c"] 23 | 24 | def ex03(self): 25 | self.exercise_files = ["ft_atoi.c"] 26 | self.test_files = ["main.c"] 27 | 28 | def ex04(self): 29 | self.exercise_files = ["ft_putnbr_base.c"] 30 | self.test_files = ["main.c"] 31 | 32 | def ex05(self): 33 | self.exercise_files = ["ft_atoi_base.c"] 34 | self.test_files = ["main.c"] 35 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_calloc.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int test_single_calloc(int test_number, size_t count, size_t size) 5 | { 6 | set_signature_tn(test_number, "ft_calloc(%zu, %zu)", count, size); 7 | 8 | reset_malloc_mock(); 9 | void *res_calloc = ft_calloc(count, size); 10 | void *res_std = calloc(count, size); 11 | 12 | int result = check_mem_size(res_calloc, count * size); 13 | result = same_mem(res_std, res_calloc, count * size) && result; 14 | result = check_leaks(res_calloc) && result; 15 | 16 | null_check(ft_calloc(count, size), result); 17 | return result; 18 | } 19 | 20 | int test_calloc() 21 | { 22 | int res = 1; 23 | 24 | res = test_single_calloc(1, 0, 10) && res; 25 | res = test_single_calloc(2, 10, 0) && res; 26 | res = test_single_calloc(3, 10, sizeof(long)) && res; 27 | 28 | return res; 29 | } 30 | 31 | int main() 32 | { 33 | handle_signals_with_time(); 34 | test(calloc); 35 | } 36 | -------------------------------------------------------------------------------- /testers/printf/UnitTest.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from halo import Halo 4 | from testers.BaseExecutor import BaseExecutor 5 | 6 | logger = logging.getLogger('pf-unit') 7 | 8 | 9 | class UnitTest(BaseExecutor): 10 | 11 | name = 'printf-unit-test' 12 | folder = 'unit-test' 13 | git_url = 'https://github.com/alelievr/printf-unit-test' 14 | 15 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 16 | super().__init__(tests_dir, temp_dir, to_execute, missing) 17 | 18 | def execute(self): 19 | if not self.exec_bonus: 20 | return [] 21 | with Halo(self.get_info_message("Compiling tests")) as spinner: 22 | self.call_make_command('', self.exec_bonus, True, spinner=spinner) 23 | output = self.run_tests("./run_test -e -r") 24 | print() 25 | return self.result("Total tested" not in output.splitlines()[-1]) 26 | 27 | def check_errors(self, output): 28 | if output: 29 | raise Exception("Problem compiling tests") 30 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strrchr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strrchr(int test_number, char *str, int ch) 5 | { 6 | set_signature_tn(test_number, "ft_strrchr(%p: \"%s\", %i: %s)", str, str, ch, escape_chr(ch)); 7 | char *res = ft_strrchr(str, ch); 8 | char *res_std = strrchr(str, ch); 9 | 10 | return same_offset(str, res_std, str, res); 11 | } 12 | 13 | int test_strrchr(void) 14 | { 15 | int res = 1; 16 | 17 | res = single_test_strrchr(1, "teste", 'e') && res; 18 | res = single_test_strrchr(2, "teste", '\0') && res; 19 | res = single_test_strrchr(3, "xteste", 'x') && res; 20 | res = single_test_strrchr(4, "teste", 'x') && res; 21 | 22 | res = single_test_strrchr(5, "teste", 1024 + 'e') && res; 23 | res = single_test_strrchr(6, "teste", 1024) && res; 24 | res = single_test_strrchr(7, "pepe y cparlos", 'c') && res; 25 | 26 | return res; 27 | } 28 | 29 | int main() 30 | { 31 | handle_signals_with_time(); 32 | test(strrchr); 33 | } 34 | -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/file_utils.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FILE_UTILS_H 3 | #define FILE_UTILS_H 4 | #include "utils/utils.h" 5 | 6 | #define TEST(title, code) \ 7 | BASE_TEST(title, { \ 8 | code; \ 9 | res = leak_check() && res; \ 10 | res = null_check_gnl(_title) && res; \ 11 | }) 12 | 13 | #define test_gnl(fd, expected) res = test_gnl_func(fd, expected, _title) && res; 14 | #define test_gnl_limits(fd, expected, line, content) res = test_gnl_func_limits(fd, expected, line, content, _title) && res; 15 | 16 | 17 | extern int next_read_error; 18 | 19 | /* for file tester */ 20 | int leak_check(); 21 | int test_gnl_func(int fd, char *expected, char *input); 22 | int test_gnl_func_limits(int fd, char *expected, int line, char *content, char *input); 23 | int silent_gnl_test(int fd, char *expected); 24 | int null_check_gnl(char *file); 25 | void print_file_content(char * content); 26 | 27 | #endif -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Launch libft test", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${fileDirname}/${fileBasenameNoExtension}", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${fileDirname}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "lldb", 18 | "preLaunchTask": "libft test" 19 | }, 20 | { 21 | "name": "Launch gnl bonus test", 22 | "type": "cppdbg", 23 | "request": "launch", 24 | "program": "${fileDirname}/test1.out", 25 | "args": [], 26 | "stopAtEntry": false, 27 | "cwd": "${fileDirname}", 28 | "environment": [], 29 | "externalConsole": false, 30 | "MIMode": "lldb", 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /tests/libft/fsoares/test_memchr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_memchr(int test_number, char *str, int ch, size_t n) 5 | { 6 | set_signature_tn(test_number, "ft_memchr(%p, %i(%x): %s, %zu)", str, ch, ch % 0x100, escape_chr(ch), n); 7 | char *res = ft_memchr(str, ch, n); 8 | char *res_std = memchr(str, ch, n); 9 | 10 | int result = same_offset(str, res_std, str, res); 11 | if (!result) { 12 | fprintf(errors_file, YEL "Memory content:\n" NC); 13 | print_mem_full(str, 0x30); 14 | fprintf(errors_file, "\n"); 15 | } 16 | return result; 17 | } 18 | 19 | int test_memchr(void) 20 | { 21 | int res = 1; 22 | char str[MEM_SIZE]; 23 | 24 | single_test_memchr(1, rand_bytes(str, 0x31), 123, 0); 25 | for (int i = 0; i < REPETITIONS && res; i++) { 26 | res = single_test_memchr(2 + i, rand_bytes(str, 0x31), rand() % 0x400, rand() % 0x30) && res; 27 | } 28 | return res; 29 | } 30 | 31 | int main() 32 | { 33 | handle_signals_with_time(); 34 | test(memchr); 35 | } 36 | -------------------------------------------------------------------------------- /testers/libft/BaseExecutor.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | 4 | from utils.TerminalColors import TC 5 | 6 | logger = logging.getLogger() 7 | ansi_columns = re.compile(r'\x1B(?:\[[0-?]*G)') 8 | ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') 9 | 10 | PART_1_FUNCTIONS = [ 11 | "isalpha", "isdigit", "isalnum", "isascii", "isprint", "strlen", "memset", "bzero", "memcpy", "memmove", "strlcpy", 12 | "strlcat", "toupper", "tolower", "strchr", "strrchr", "strncmp", "memchr", "memcmp", "strnstr", "atoi", "calloc", 13 | "strdup" 14 | ] 15 | 16 | PART_2_FUNCTIONS = [ 17 | "substr", "strjoin", "strtrim", "split", "itoa", "strmapi", "striteri", "putchar_fd", "putstr_fd", "putendl_fd", 18 | "putnbr_fd" 19 | ] 20 | 21 | BONUS_FUNCTIONS = [ 22 | "lstnew", "lstadd_front", "lstsize", "lstlast", "lstadd_back", "lstdelone", "lstclear", "lstiter", "lstmap" 23 | ] 24 | 25 | 26 | def remove_ansi_colors(text): 27 | return ansi_escape.sub('', ansi_columns.sub(' ', text)) 28 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strtrim.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strtrim(int test_number, char *str, char *set, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_strtrim(\"%s\", \"%s\")", str, set); 7 | check_alloc_str_return(ft_strtrim(str, set), expected); 8 | } 9 | 10 | int test_strtrim() 11 | { 12 | int res = single_test_strtrim(1, "", "", ""); 13 | res = single_test_strtrim(2, "abcd", "", "abcd") && res; 14 | res = single_test_strtrim(3, "", "cdef", "") && res; 15 | res = single_test_strtrim(4, " . abcd", " ", ". abcd") && res; 16 | res = single_test_strtrim(5, "ab cd f ", " ", "ab cd f") && res; 17 | res = single_test_strtrim(6, "xxxz test with x and z and x . zx xx z", "z x", "test with x and z and x .") && res; 18 | res = single_test_strtrim(7, " abxfg ", "x", " abxfg ") && res; 19 | res = single_test_strtrim(8, ".teste, bla ,.,.", ",.", "teste, bla ") && res; 20 | return res; 21 | } 22 | 23 | int main() 24 | { 25 | handle_signals_with_time(); 26 | test(strtrim); 27 | } 28 | -------------------------------------------------------------------------------- /utils/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # FIXME: Remove after some time (because of the updater) 4 | 5 | cd "$HOME" || exit 6 | 7 | mkdir temp_____ 8 | 9 | if [ "$(uname)" != "Darwin" ]; then 10 | echo "Admin permissions need to install newer packages" 11 | sudo apt install libbsd-dev libncurses-dev 12 | fi 13 | 14 | cd temp_____ || exit 15 | rm -rf francinette 16 | 17 | # download github 18 | echo "Downloading francinette repo..." 19 | git clone --quiet --recursive https://github.com/xicodomingues/francinette.git 2> /dev/null 20 | 21 | cp -r francinette .. 2> /dev/null 22 | 23 | cd "$HOME" || exit 24 | rm -rf temp_____ 25 | 26 | cd "$HOME"/francinette || exit 27 | 28 | # activate venv 29 | . venv/bin/activate 30 | 31 | echo "Updating python dependencies..." 32 | # install requirements 33 | if ! pip3 install --disable-pip-version-check -q -r requirements.txt ; then 34 | echo "Problem launching the installer. Contact me (fsoares- on slack)" 35 | exit 1 36 | fi 37 | 38 | echo -e "\033[1;37mFrancinette is updated. You can use it again!\033[0m" 39 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 15:43:16 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 15:48:00 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_comb(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_comb(); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 16:37:56 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 17:19:54 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_comb2(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_comb2(); 18 | return (0); 19 | } 20 | -------------------------------------------------------------------------------- /doc/fsoares-.zsh-theme: -------------------------------------------------------------------------------- 1 | # ZSH Theme emulating the Fish shell's default prompt. 2 | 3 | _fishy_collapsed_wd() { 4 | local i pwd 5 | pwd=("${(s:/:)PWD/#$HOME/~}") 6 | echo "${(j:/:)pwd}" 7 | } 8 | 9 | _show_git_status() { 10 | if [[ "$(git_repo_name)" != "" ]]; then 11 | echo "$(git_prompt_status)%{$fg_bold[blue]%} " 12 | fi 13 | } 14 | 15 | PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" 16 | PROMPT+='%{$fg[cyan]%}$(_fishy_collapsed_wd)%{$reset_color%} ' 17 | PROMPT+='$(git_prompt_info)$(_show_git_status)%{$fg_bold[magenta]%}»%{$reset_color%} ' 18 | 19 | 20 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[white]%}" 21 | ZSH_THEME_GIT_PROMPT_SUFFIX="" 22 | ZSH_THEME_GIT_PROMPT_DIRTY="" 23 | ZSH_THEME_GIT_PROMPT_CLEAN="" 24 | 25 | ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[green]%}+" 26 | ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[blue]%}!" 27 | ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[red]%}-" 28 | ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[magenta]%}>" 29 | ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[yellow]%}#" 30 | ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}?" 31 | -------------------------------------------------------------------------------- /utils/ExecutionContext.py: -------------------------------------------------------------------------------- 1 | from argparse import Namespace 2 | from dataclasses import dataclass 3 | from pathlib import Path 4 | from typing import List 5 | 6 | from rich.console import Console 7 | 8 | console = Console() 9 | 10 | 11 | @dataclass 12 | class TestRunInfo: 13 | source_dir: Path # location of the code to test 14 | base_dir: Path # location of francinette 15 | ex_to_execute: List[str] 16 | args: Namespace 17 | has_bonus: bool = False 18 | 19 | 20 | _saved_context = None 21 | 22 | 23 | def set_contex(info: TestRunInfo): 24 | global _saved_context 25 | _saved_context = info 26 | 27 | 28 | def get_context() -> TestRunInfo: 29 | return _saved_context 30 | 31 | 32 | def set_bonus(value): 33 | _saved_context.has_bonus = value 34 | 35 | 36 | def has_bonus() -> bool: 37 | return _saved_context.has_bonus 38 | 39 | 40 | def is_strict(): 41 | return _saved_context.args.strict 42 | 43 | 44 | def get_timeout(): 45 | return int(_saved_context.args.timeout) 46 | 47 | 48 | def set_timeout(timeout: int): 49 | _saved_context.args.timeout = timeout 50 | -------------------------------------------------------------------------------- /testers/get_next_line/GetNextLine.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from pathlib import Path 3 | from testers.BaseTester import BaseTester 4 | from testers.get_next_line.Fsoares import Fsoares 5 | 6 | from testers.get_next_line.Tripouille import Tripouille 7 | from utils.ExecutionContext import TestRunInfo, has_bonus, is_strict, set_bonus 8 | from utils.Utils import show_banner 9 | 10 | logger = logging.getLogger("gnl") 11 | 12 | 13 | class GetNextLine(BaseTester): 14 | 15 | name = "get_next_line" 16 | my_tester = Fsoares 17 | testers = [Tripouille, Fsoares] 18 | timeout = 10 19 | 20 | def __init__(self, info: TestRunInfo) -> None: 21 | super().__init__(info) 22 | if (info.source_dir / "get_next_line_bonus.c").exists() \ 23 | and not info.args.mandatory: 24 | logger.info("Has bonus") 25 | set_bonus(True) 26 | self.execute_testers() 27 | 28 | @staticmethod 29 | def is_project(current_path): 30 | file_path = current_path / 'get_next_line.c' 31 | logger.info(f"Testing: {file_path}") 32 | if not file_path.exists(): 33 | return False 34 | return GetNextLine 35 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstnew.c: -------------------------------------------------------------------------------- 1 | #include "list_utils.h" 2 | 3 | int check_allocs(void *content, t_list *expected) 4 | { 5 | t_list *res = ft_lstnew(content); 6 | int result = same_list_elem(expected, res); 7 | if (!result){ 8 | fprintf(errors_file, "Check that you are setting " MAG "new_node->next" NC " to NULL\n\n"); 9 | } 10 | result = check_mem_size(res, sizeof(t_list)) && result; 11 | result = check_leaks(res) && result; 12 | null_check(ft_lstnew(content), result); 13 | return result; 14 | } 15 | 16 | int test_single_lstnew(int test_number, char *content, t_list *expected) 17 | { 18 | set_signature_tn(test_number, "ft_lstnew(%p: %s)", content, escape_str(content)); 19 | expected->content = content; 20 | return check_allocs(content, expected); 21 | } 22 | 23 | int test_lstnew() 24 | { 25 | t_list expected; 26 | expected.next = NULL; 27 | int res = test_single_lstnew(1, NULL, &expected); 28 | res = test_single_lstnew(2, "hahaha", &expected) && res; 29 | return res; 30 | } 31 | 32 | int main() 33 | { 34 | handle_signals_with_time(); 35 | test(lstnew); 36 | } 37 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strlcpy.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strlcpy(int test_number, char *dest, char *dest_std, char *src, int n) 5 | { 6 | int result = 1; 7 | reset(dest, dest_std, MEM_SIZE); 8 | 9 | set_signature_tn(test_number, "ft_strlcpy(dest, \"%s\", %i)", src, n); 10 | 11 | int res = ft_strlcpy(dest, src, n); 12 | int res_std = strlcpy(dest_std, src, n); 13 | result = same_value(res_std, res); 14 | return same_mem(dest_std, dest, MEM_SIZE) && result; 15 | } 16 | 17 | int test_strlcpy(void) 18 | { 19 | char dest[MEM_SIZE]; 20 | char dest_std[MEM_SIZE]; 21 | 22 | int res = 1; 23 | res = single_test_strlcpy(1, dest, dest_std, "aaa", 0) && res; 24 | res = single_test_strlcpy(2, dest, dest_std, "aaa", 2) && res; 25 | res = single_test_strlcpy(3, dest, dest_std, "aaa", 3) && res; 26 | res = single_test_strlcpy(4, dest, dest_std, "aaa", 4) && res; 27 | res = single_test_strlcpy(5, dest, dest_std, "aasdjj;s;sa", 100) && res; 28 | return res; 29 | } 30 | 31 | int main() 32 | { 33 | handle_signals_with_time(); 34 | test(strlcpy); 35 | } 36 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 14:34:29 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 14:35:24 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_numbers(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_numbers(); 18 | ft_print_numbers(); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 13:40:46 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/14 18:39:58 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_alphabet(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_alphabet(); 18 | ft_print_alphabet(); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstiter.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | void count_chars(void *s) 5 | { 6 | char *str = (char *)s; 7 | sprintf(str, "%zu", strlen(str)); 8 | } 9 | 10 | int single_test_lstiter(int test_number, t_list **initial, t_list ** expected) 11 | { 12 | char *l_str = list_to_str(initial); 13 | set_signature_tn(test_number, "ft_lstiter(%s, [(s) => (s = strlen(s))])", l_str); free(l_str); 14 | ft_lstiter(*initial, count_chars); 15 | int res = same_list(expected, initial); 16 | 17 | null_null_check(ft_lstiter(*initial, count_chars), res); 18 | return res; 19 | } 20 | 21 | int test_lstiter() 22 | { 23 | int res = single_test_lstiter(1, create_list(0), create_list(0)); 24 | res = single_test_lstiter(2, create_list(1, strdup("one")), create_list(1, "3")) && res; 25 | res = single_test_lstiter(3, 26 | create_list(5, strdup("um"), strdup("dois"), strdup("tres"), strdup("quatro"), strdup("cinco")), 27 | create_list(5, "2", "4", "4", "6", "5")) && res; 28 | 29 | return res; 30 | } 31 | 32 | int main() 33 | { 34 | handle_signals_with_time(); 35 | test(lstiter); 36 | } 37 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 10:08:29 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 11:06:00 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_putchar(char c); 14 | 15 | int main(void) 16 | { 17 | ft_putchar('x'); 18 | ft_putchar('\n'); 19 | ft_putchar('y'); 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_memcpy.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_memcpy(int test_number, char *dest, char *dest_std, char *src, char *src_std, int n) 5 | { 6 | reset(dest, dest_std, MEM_SIZE); 7 | reset(src, src_std, MEM_SIZE); 8 | 9 | rand_str(src , rand() % 55 + 1); 10 | memcpy(src_std, src, 100); 11 | 12 | char *res = ft_memcpy(dest, src, n); 13 | char *res_std = memcpy(dest_std, src_std, n); 14 | 15 | set_signature_tn(test_number, "ft_memcpy(dest, src: %s, n: %i)", escape_str(src), n); 16 | return (same_return(dest, res) && same_mem(res_std, res, MEM_SIZE)); 17 | } 18 | 19 | int test_memcpy(void) 20 | { 21 | char dest[MEM_SIZE]; 22 | char dest_std[MEM_SIZE]; 23 | 24 | char src[MEM_SIZE]; 25 | char src_std[MEM_SIZE]; 26 | 27 | int res = 1; 28 | 29 | res = single_test_memcpy(1, dest, dest_std, src, src_std, 0); 30 | for (int n = 0; n < REPETITIONS && res; n++) 31 | res = single_test_memcpy(2 + n, dest, dest_std, src, src_std, rand() % 70) && res; 32 | 33 | return res; 34 | } 35 | 36 | int main() 37 | { 38 | handle_signals_with_time(); 39 | test(memcpy); 40 | } 41 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 13:46:16 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 14:33:50 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_strlen(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("%d %d", ft_strlen("hel\nlo"), ft_strlen("")); 20 | } 21 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/17 02:35:00 by badam #+# #+# */ 9 | /* Updated: 2019/06/17 02:36:59 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_ten_queens_puzzle(void); 16 | 17 | int main(void) 18 | { 19 | printf("\n%d solutions\n", ft_ten_queens_puzzle()); 20 | } 21 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strlcat.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | 5 | int single_test_strlcat(int test_number, char *dest, char *dest_std, char *orig, char *src, int n) 6 | { 7 | int result = 1; 8 | 9 | set_signature_tn(test_number, "ft_strlcat(\"%s\", \"%s\", %i)", orig, src, n); 10 | reset_with(dest, dest_std, orig, MEM_SIZE); 11 | 12 | int res = ft_strlcat(dest, src, n); 13 | int res_std = strlcat(dest_std, src, n); 14 | result = same_value(res_std, res); 15 | return same_mem(dest_std, dest, (n / 16 + 1) * 16) && result; 16 | } 17 | 18 | int test_strlcat(void) 19 | { 20 | char dest[MEM_SIZE]; 21 | char dest_std[MEM_SIZE]; 22 | 23 | int res = 1; 24 | for (int i = 0; i < 8; i++) 25 | res = single_test_strlcat(1 + i, dest, dest_std, "pqrstuvwxyz", "abcd", i) && res; 26 | 27 | res = single_test_strlcat(9, dest, dest_std, "pqrstuvwxyz", "abcd", 20) && res; 28 | 29 | for (int i = 10; i < 18; i++) 30 | res = single_test_strlcat(i, dest, dest_std, "pqrs", "abcdefghi", i) && res; 31 | return res; 32 | } 33 | 34 | int main() 35 | { 36 | handle_signals_with_time(); 37 | test(strlcat); 38 | } 39 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 13:40:46 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 14:30:21 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | void ft_print_reverse_alphabet(void); 14 | 15 | int main(void) 16 | { 17 | ft_print_reverse_alphabet(); 18 | ft_print_reverse_alphabet(); 19 | return (0); 20 | } 21 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_striteri.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_striteri(int test_number, char *str, void (*fn)(unsigned int, char *), char *func, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_striteri(\"%s\", %s)", str, func); 7 | 8 | char buffer[20]; 9 | strcpy(buffer, str); 10 | int result = 1; 11 | ft_striteri(buffer, fn); 12 | result = same_string(expected, buffer); 13 | result = check_leaks(NULL) && result; 14 | null_null_check(ft_striteri(buffer, fn), result); 15 | return result; 16 | } 17 | 18 | void add(unsigned int i, char *c) { 19 | *c = (char)(i + *c); 20 | } 21 | 22 | void to_char_zero(unsigned int i, char *c) { 23 | *c = i - i + '0'; 24 | } 25 | 26 | int test_striteri() 27 | { 28 | int res = single_test_striteri(1, "", add, "{(i, c) => i + c}", ""); 29 | res = single_test_striteri(2, "abcd0 ", add, "{(i, c) => i + c}", "aceg4%") && res; 30 | res = single_test_striteri(3, "abcdfsdfs", to_char_zero, "{(i, c) => '0'}", "000000000") && res; 31 | 32 | return res; 33 | } 34 | 35 | int main() 36 | { 37 | handle_signals_with_time(); 38 | test(striteri); 39 | } 40 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 13:46:16 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 14:18:34 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_putstr(char *str); 15 | 16 | int main(void) 17 | { 18 | ft_putstr("hello"); 19 | write(1, "\n", 1); 20 | ft_putstr("holla\noutro"); 21 | } 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Francisco 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 10:08:29 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 14:58:54 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_is_negative(char c); 16 | 17 | int main(void) 18 | { 19 | ft_is_negative(1); 20 | ft_is_negative(0); 21 | ft_is_negative(-1); 22 | return (0); 23 | } 24 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstadd_back.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | int single_test_lstadd_back(int test_number, t_list **list, t_list *new, t_list **expected) 5 | { 6 | char *list_str = list_to_str(list); 7 | char *node_str = node_to_str(new); 8 | set_signature_tn(test_number, "ft_lstadd_back(%s, %s)", list_str, node_str); 9 | free(list_str); free(node_str); 10 | 11 | ft_lstadd_back(list, new); 12 | int result = same_list(expected, list); 13 | null_null_check(ft_lstadd_back(list, new), result); 14 | return result; 15 | } 16 | 17 | int test_lstadd_back() 18 | { 19 | int res = single_test_lstadd_back(1, 20 | create_list(0), 21 | lstnew("last"), 22 | create_list(1, "last")); 23 | res = single_test_lstadd_back(2, 24 | create_list(1, "first"), 25 | lstnew("last"), 26 | create_list(2, "first", "last")) && res; 27 | res = single_test_lstadd_back(3, 28 | create_list(5, "one", "two", "three", "four", "five"), 29 | lstnew("last"), 30 | create_list(6, "one", "two", "three", "four", "five", "last")) && res; 31 | return res; 32 | } 33 | 34 | int main() 35 | { 36 | handle_signals_with_time(); 37 | test(lstadd_back); 38 | } 39 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 12:40:24 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 12:55:29 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_ft(int *ptr); 15 | 16 | int main(void) 17 | { 18 | int a; 19 | 20 | a = 567; 21 | ft_ft(&a); 22 | printf("%d\n", a); 23 | a = 234; 24 | printf("%d\n", a); 25 | ft_ft(&a); 26 | printf("%d", a); 27 | } 28 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_putchar_fd.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_putchar(int test_n, char c, int fd) 5 | { 6 | set_signature_tn(test_n, "ft_putchar_fd(%i:%s, fd: %i)", c, escape_chr(c), fd); 7 | 8 | ft_putchar_fd(c, fd); 9 | return check_leaks(NULL); 10 | } 11 | 12 | int test_putchar_fd() 13 | { 14 | int fd = open("fsoares", O_RDWR | O_CREAT); 15 | 16 | int res = single_test_putchar(1, 'a', fd); 17 | res = single_test_putchar(2, 'x', fd) && res; 18 | res = single_test_putchar(3, 'y', fd) && res; 19 | res = single_test_putchar(4, 'z', fd) && res; 20 | res = single_test_putchar(5, '\n', fd) && res; 21 | 22 | lseek(fd, SEEK_SET, 0); 23 | char content[10] = {0}; 24 | read(fd, content, 10); 25 | 26 | char *expected = "axyz\n"; 27 | if(strcmp(content, expected) != 0) 28 | res = error("expected: %s, content of the file: %s\n", escape_str(expected), escape_str(content)) && res; 29 | 30 | set_signature_tn(6, "ft_putchar_fd(%i:%s, fd: %i)", 't', escape_chr('t'), fd); 31 | null_null_check(ft_putchar_fd('t', fd), res); 32 | 33 | remove("./fsoares"); 34 | return res; 35 | } 36 | 37 | int main() 38 | { 39 | handle_signals_with_time(); 40 | test(putchar_fd); 41 | } 42 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_memmove.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_memmove(int test_number, char *dest, char *dest_std, char *src, char *src_std, char *value, int n) 5 | { 6 | reset(dest, dest_std, MEM_SIZE); 7 | reset(src, src_std, MEM_SIZE); 8 | strcpy(src, value); 9 | strcpy(src_std, value); 10 | 11 | set_signature_tn(test_number, "ft_memmove(%p, %p: \"%s\", %i)", dest, src, src, n); 12 | 13 | char *result = ft_memmove(dest, src, n); 14 | char *expected = memmove(dest_std, src_std, n); 15 | return (same_return(dest, result) && same_mem(expected, result, MEM_SIZE)); 16 | } 17 | 18 | int test_memmove(void) 19 | { 20 | char dest[MEM_SIZE + 10]; 21 | char dest_std[MEM_SIZE + 10]; 22 | 23 | int res = 1; 24 | res = single_test_memmove(1, dest, dest_std, dest + 2, dest_std + 2, "123456", 4) && res; 25 | res = single_test_memmove(2, dest + 2, dest_std + 2, dest, dest_std, "123456", 4) && res; 26 | res = single_test_memmove(3, dest, dest_std, dest, dest_std, "123456", 4) && res; 27 | res = single_test_memmove(4, dest + 2, dest_std + 2, dest, dest_std, "123456", 0) && res; 28 | 29 | return res; 30 | } 31 | 32 | int main() 33 | { 34 | handle_signals_with_time(); 35 | test(memmove); 36 | } 37 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 21:52:49 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_alpha(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("\"abc\": %i\n", ft_str_is_alpha("abc")); 20 | printf("\"\": %i\n", ft_str_is_alpha("")); 21 | printf("\"abcdasda1d\": %i\n", ft_str_is_alpha("abcdasda1d")); 22 | } 23 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_putstr_fd.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_putstr(int test_number, char *str, int fd) 5 | { 6 | set_signature_tn(test_number, "ft_putstr_fd(%s, fd: %i)", escape_str(str), fd); 7 | 8 | ft_putstr_fd(str, fd); 9 | return check_leaks(NULL); 10 | } 11 | 12 | int test_putstr_fd() 13 | { 14 | int fd = open("fsoares", O_RDWR | O_CREAT); 15 | 16 | int res = single_test_putstr(1, "abcdef", fd); 17 | res = single_test_putstr(2, "\n1234", fd) && res; 18 | res = single_test_putstr(3, "\t567", fd) && res; 19 | res = single_test_putstr(4, "", fd) && res; 20 | res = single_test_putstr(5, "\nend!", fd) && res; 21 | 22 | lseek(fd, SEEK_SET, 0); 23 | char content[100] = {0}; 24 | read(fd, content, 100); 25 | 26 | char *expected = "abcdef\n1234\t567\nend!"; 27 | if(strcmp(content, expected) != 0) 28 | res = error("expected: %s, content of the file: %s\n", escape_str(expected), escape_str(content)) && res; 29 | 30 | set_signature_tn(6, "ft_putstr_fd(\"%s\", fd: %i)", "teste", fd); 31 | null_null_check(ft_putstr_fd("teste", fd), res); 32 | 33 | remove("./fsoares"); 34 | return res; 35 | } 36 | 37 | int main() 38 | { 39 | handle_signals_with_time(); 40 | test(putstr_fd); 41 | } 42 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/20 16:37:07 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int ft_putstr(char *str); 18 | 19 | int main() { 20 | ft_putstr(""); 21 | write(1, "--\n", 3); 22 | ft_putstr("hola!\n"); 23 | char s1[10] = "asdfsfg"; 24 | s1[3] = 11; 25 | ft_putstr(s1); 26 | } -------------------------------------------------------------------------------- /testers/minitalk/Minitalk.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | from testers.BaseTester import BaseTester 4 | from testers.minitalk.Fsoares import Fsoares 5 | from utils.ExecutionContext import TestRunInfo 6 | from utils.Utils import is_makefile_project 7 | 8 | logger = logging.getLogger('minitalk') 9 | 10 | class Minitalk(BaseTester): 11 | 12 | name = "minitalk" 13 | my_tester = Fsoares 14 | testers = [Fsoares] 15 | timeout = 30 16 | 17 | def __init__(self, info: TestRunInfo) -> None: 18 | super().__init__(info) 19 | self.execute_testers() 20 | pass 21 | 22 | @staticmethod 23 | def is_project(current_path): 24 | if (Minitalk.makefile_contains(current_path, "server") 25 | and Minitalk.makefile_contains(current_path, "client")): 26 | return Minitalk 27 | return False 28 | 29 | @staticmethod 30 | def makefile_contains(current_path, name): 31 | make_path = current_path / "Makefile" 32 | name_matcher = re.compile(fr".*\b({name})(?![\w\.]).*") 33 | logger.info(f"Makefile path: {make_path.resolve()}") 34 | if not make_path.exists(): 35 | return False 36 | with open(make_path, "r") as mk: 37 | for line in mk.readlines(): 38 | if name_matcher.match(line): 39 | return True 40 | return False 41 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 22:03:47 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_numeric(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("\"123\": %i\n", ft_str_is_numeric("123")); 20 | printf("\"\": %i\n", ft_str_is_numeric("")); 21 | printf("\"1234567a89\": %i\n", ft_str_is_numeric("1234567a89")); 22 | } 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tests/libft/alelievr"] 2 | path = tests/libft/alelievr 3 | url = https://github.com/xicodomingues/libft-unit-test 4 | [submodule "tests/libft/war-machine"] 5 | path = tests/libft/war-machine 6 | url = https://github.com/xicodomingues/libft-war-machine 7 | [submodule "tests/libft/Tripouille"] 8 | path = tests/libft/Tripouille 9 | url = https://github.com/xicodomingues/libftTester 10 | [submodule "tests/get_next_line/gnlTester"] 11 | path = tests/get_next_line/gnlTester 12 | url = https://github.com/xicodomingues/gnlTester 13 | [submodule "tests/printf/printfTester"] 14 | path = tests/printf/printfTester 15 | url = https://github.com/xicodomingues/printfTester 16 | [submodule "tests/printf/unit-test"] 17 | path = tests/printf/unit-test 18 | url = https://github.com/xicodomingues/printf-unit-test 19 | [submodule "tests/printf/ft_printf_test"] 20 | path = tests/printf/ft_printf_test 21 | url = https://github.com/xicodomingues/ft_printf_test 22 | [submodule "tests/pipex/pipex-tester"] 23 | path = tests/pipex/pipex-tester 24 | url = https://github.com/xicodomingues/pipex-tester 25 | [submodule "tests/pipex/pipexMedic"] 26 | path = tests/pipex/pipexMedic 27 | url = https://github.com/xicodomingues/pipexMedic 28 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_putendl_fd.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_putendl(int test_number, char *str, int fd) 5 | { 6 | set_signature_tn(test_number, "ft_putendl_fd(%s, fd: %i)", escape_str(str), fd); 7 | 8 | ft_putendl_fd(str, fd); 9 | return check_leaks(NULL); 10 | } 11 | 12 | int test_putendl_fd() 13 | { 14 | int fd = open("fsoares", O_RDWR | O_CREAT); 15 | 16 | int res = single_test_putendl(1, "", fd); 17 | res = single_test_putendl(2, "abcdef", fd) && res; 18 | res = single_test_putendl(3, "1234", fd) && res; 19 | res = single_test_putendl(4, "567", fd) && res; 20 | res = single_test_putendl(5, "end!", fd) && res; 21 | 22 | lseek(fd, SEEK_SET, 0); 23 | char content[100] = {0}; 24 | read(fd, content, 100); 25 | 26 | char *expected = "\nabcdef\n1234\n567\nend!\n"; 27 | if(strcmp(content, expected) != 0) 28 | res = error("expected: %s, content of the file: %s\n", escape_str(expected), escape_str(content)) && res; 29 | 30 | set_signature_tn(6, "ft_putendl_fd(\"%s\", fd: %i)", "teste", fd); 31 | null_null_check(ft_putendl_fd("teste", fd), res); 32 | 33 | remove("./fsoares"); 34 | return res; 35 | } 36 | 37 | int main() 38 | { 39 | handle_signals_with_time(); 40 | test(putendl_fd); 41 | } 42 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 13:25:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 13:28:31 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_swap(int *a, int *b); 15 | 16 | int main(void) 17 | { 18 | int a; 19 | int b; 20 | 21 | a = 13; 22 | b = 23; 23 | ft_swap(&a, &b); 24 | printf("%d %d\n", a, b); 25 | a = -23; 26 | b = 45; 27 | ft_swap(&a, &b); 28 | printf("%d %d\n", a, b); 29 | } 30 | -------------------------------------------------------------------------------- /testers/cpiscine/C01Tester.py: -------------------------------------------------------------------------------- 1 | from testers.cpiscine.CommonTester import CommonTester 2 | from utils.ExecutionContext import TestRunInfo 3 | 4 | 5 | class C01Tester(CommonTester): 6 | 7 | name = "c01" 8 | 9 | def __init__(self, info: TestRunInfo): 10 | super().__init__(info) 11 | 12 | def ex00(self): 13 | self.exercise_files = ["ft_ft.c"] 14 | self.test_files = ["main.c"] 15 | 16 | def ex01(self): 17 | self.exercise_files = ["ft_ultimate_ft.c"] 18 | self.test_files = ["main.c"] 19 | 20 | def ex02(self): 21 | self.exercise_files = ["ft_swap.c"] 22 | self.test_files = ["main.c"] 23 | 24 | def ex03(self): 25 | self.exercise_files = ["ft_div_mod.c"] 26 | self.test_files = ["main.c"] 27 | 28 | def ex04(self): 29 | self.exercise_files = ["ft_ultimate_div_mod.c"] 30 | self.test_files = ["main.c"] 31 | 32 | def ex05(self): 33 | self.exercise_files = ["ft_putstr.c"] 34 | self.test_files = ["main.c"] 35 | 36 | def ex06(self): 37 | self.exercise_files = ["ft_strlen.c"] 38 | self.test_files = ["main.c"] 39 | 40 | def ex07(self): 41 | self.exercise_files = ["ft_rev_int_tab.c"] 42 | self.test_files = ["main.c"] 43 | 44 | def ex08(self): 45 | self.exercise_files = ["ft_sort_int_tab.c"] 46 | self.test_files = ["main.c"] 47 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 13:25:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 13:42:34 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_ultimate_div_mod(int *a, int *b); 15 | 16 | int main(void) 17 | { 18 | int a; 19 | int b; 20 | 21 | a = 123; 22 | b = 10; 23 | ft_ultimate_div_mod(&a, &b); 24 | printf("%d %d\n", a, b); 25 | a = -123; 26 | b = 15; 27 | ft_ultimate_div_mod(&a, &b); 28 | printf("%d %d\n", a, b); 29 | } 30 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_putnbr_fd.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_putnbr(int test_number, int n, int fd) 5 | { 6 | set_signature_tn(test_number, "ft_putnbr_fd(%i, fd: %i)", n, fd); 7 | 8 | ft_putnbr_fd(n, fd); 9 | ft_putendl_fd("", fd); 10 | return check_leaks(NULL); 11 | } 12 | 13 | int test_putnbr_fd() 14 | { 15 | int fd = open("fsoares", O_RDWR | O_CREAT); 16 | 17 | int res = single_test_putnbr(1, 0, fd); 18 | res = single_test_putnbr(2, 10000043, fd) && res; 19 | res = single_test_putnbr(3, -10000043, fd) && res; 20 | res = single_test_putnbr(4, INT_MAX, fd) && res; 21 | res = single_test_putnbr(5, INT_MIN, fd) && res; 22 | 23 | lseek(fd, SEEK_SET, 0); 24 | char content[100] = {0}; 25 | read(fd, content, 100); 26 | 27 | char expected[1000]; 28 | sprintf(expected, "0\n10000043\n-10000043\n%i\n%i\n", INT_MAX, INT_MIN); 29 | if(strcmp(content, expected) != 0) 30 | res = error("expected: %s, content of the file: %s\n", escape_str(expected), escape_str(content)) && res; 31 | 32 | set_signature_tn(6, "ft_putnbr_fd(%i, fd: %i)", 10000, fd); 33 | null_null_check(ft_putnbr_fd(10000, fd), res); 34 | 35 | remove("./fsoares"); 36 | return res; 37 | } 38 | 39 | int main() 40 | { 41 | handle_signals_with_time(); 42 | test(putnbr_fd); 43 | } 44 | -------------------------------------------------------------------------------- /testers/cpiscine/C00Tester.py: -------------------------------------------------------------------------------- 1 | from testers.cpiscine.CommonTester import CommonTester 2 | from utils.ExecutionContext import TestRunInfo 3 | 4 | 5 | class C00Tester(CommonTester): 6 | 7 | name = "c00" 8 | 9 | def __init__(self, info: TestRunInfo): 10 | super().__init__(info) 11 | 12 | def ex00(self): 13 | self.exercise_files = ["ft_putchar.c"] 14 | self.test_files = ["main.c"] 15 | 16 | def ex01(self): 17 | self.exercise_files = ["ft_print_alphabet.c"] 18 | self.test_files = ["main.c"] 19 | 20 | def ex02(self): 21 | self.exercise_files = ["ft_print_reverse_alphabet.c"] 22 | self.test_files = ["main.c"] 23 | 24 | def ex03(self): 25 | self.exercise_files = ["ft_print_numbers.c"] 26 | self.test_files = ["main.c"] 27 | 28 | def ex04(self): 29 | self.exercise_files = ["ft_is_negative.c"] 30 | self.test_files = ["main.c"] 31 | 32 | def ex05(self): 33 | self.exercise_files = ["ft_print_comb.c"] 34 | self.test_files = ["main.c"] 35 | 36 | def ex06(self): 37 | self.exercise_files = ["ft_print_comb2.c"] 38 | self.test_files = ["main.c"] 39 | 40 | def ex07(self): 41 | self.exercise_files = ["ft_putnbr.c"] 42 | self.test_files = ["main.c"] 43 | 44 | def ex08(self): 45 | self.exercise_files = ["ft_print_combn.c"] 46 | self.test_files = ["main.c"] 47 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_memset.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_memset(int test_number, char *m, char *ms, int c, int size) 5 | { 6 | char *res; 7 | char *res_std; 8 | 9 | reset(m, ms, MEM_SIZE); 10 | res_std = memset(ms, c, size); 11 | res = ft_memset(m, c, size); 12 | set_signature_tn(test_number, "ft_memset(ptr, %i: %s, %i)", c, escape_chr(c), size); 13 | return (same_return(m, res) && same_mem(res_std, res, MEM_SIZE)); 14 | } 15 | 16 | int test_memset(void) 17 | { 18 | char mem[MEM_SIZE]; 19 | char mem_std[MEM_SIZE]; 20 | 21 | int res = 1; 22 | 23 | res = single_test_memset(1, mem, mem_std, 'x', 0) && res; 24 | res = single_test_memset(2, mem, mem_std, 'g', 12) && res; 25 | res = single_test_memset(4, mem, mem_std, 300, 12) && res; 26 | res = single_test_memset(4, mem, mem_std, 257, 19) && res; 27 | 28 | int m2[MEM_SIZE]; 29 | int ms2[MEM_SIZE]; 30 | 31 | reset(m2, ms2, MEM_SIZE); 32 | int *rs = memset(ms2 + 1, 143462, 4); 33 | int *r = ft_memset(m2 + 1, 143462, 4); 34 | 35 | set_signature_tn(5, "ft_memset(ptr, %i: %s, %i)", 143462, escape_chr((char)143462), 4); 36 | res = (same_ptr(r, m2 + 1) && same_mem(rs - 1, r - 1, 0x10)) && res; 37 | return res; 38 | } 39 | 40 | int main() 41 | { 42 | handle_signals_with_time(); 43 | test(memset); 44 | } 45 | -------------------------------------------------------------------------------- /testers/cpiscine/C05Tester.py: -------------------------------------------------------------------------------- 1 | from testers.cpiscine.CommonTester import CommonTester 2 | from utils.ExecutionContext import TestRunInfo 3 | 4 | 5 | class C05Tester(CommonTester): 6 | 7 | name = "c05" 8 | 9 | def __init__(self, info: TestRunInfo): 10 | super().__init__(info) 11 | 12 | def ex00(self): 13 | self.exercise_files = ["ft_iterative_factorial.c"] 14 | self.test_files = ["main.c"] 15 | 16 | def ex01(self): 17 | self.exercise_files = ["ft_recursive_factorial.c"] 18 | self.test_files = ["main.c"] 19 | 20 | def ex02(self): 21 | self.exercise_files = ["ft_iterative_power.c"] 22 | self.test_files = ["main.c"] 23 | 24 | def ex03(self): 25 | self.exercise_files = ["ft_recursive_power.c"] 26 | self.test_files = ["main.c"] 27 | 28 | def ex04(self): 29 | self.exercise_files = ["ft_fibonacci.c"] 30 | self.test_files = ["main.c"] 31 | 32 | def ex05(self): 33 | self.exercise_files = ["ft_sqrt.c"] 34 | self.test_files = ["main.c"] 35 | 36 | def ex06(self): 37 | self.exercise_files = ["ft_is_prime.c"] 38 | self.test_files = ["main.c"] 39 | 40 | def ex07(self): 41 | self.exercise_files = ["ft_find_next_prime.c"] 42 | self.test_files = ["main.c"] 43 | 44 | def ex08(self): 45 | self.exercise_files = ["ft_ten_queens_puzzle.c"] 46 | self.test_files = ["main.c"] 47 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/20 17:57:05 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strlen(char *str); 17 | 18 | int main() { 19 | char *s = ""; 20 | printf("len of: '%s': %i\n", s, ft_strlen(s)); 21 | s = "sggdsdsg"; 22 | printf("len of: '%s': %i\n", s, ft_strlen(s)); 23 | char s1[10] = "asdfsfg"; 24 | s1[3] = 11; 25 | printf("len of: '%s': %i\n", s1, ft_strlen(s1)); 26 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "cppbuild", 6 | "label": "libft test", 7 | "command": "/usr/bin/clang", 8 | "args": [ 9 | "-fdiagnostics-color=always", 10 | "-g", 11 | "utils.c", 12 | "list_utils.c", 13 | "${file}", 14 | "malloc_mock.c", 15 | "-L.", 16 | "-lft", 17 | "-o", 18 | "${fileBasenameNoExtension}", 19 | "-ldl" 20 | ], 21 | "options": { 22 | "cwd": "${fileDirname}" 23 | }, 24 | "problemMatcher": [ 25 | "$gcc" 26 | ], 27 | "group": "build", 28 | "detail": "compiler: /usr/bin/clang" 29 | }, 30 | { 31 | "type": "cppbuild", 32 | "label": "gnl bonus test", 33 | "command": "/usr/bin/clang", 34 | "args": [ 35 | "-fdiagnostics-color=always", 36 | "-g", 37 | "-D BUFFER_SIZE=10", 38 | "-D STRICT_MEM", 39 | "utils/utils.c", 40 | "utils/file_utils.c", 41 | "utils/malloc_mock.c", 42 | "../get_next_line_bonus.c", 43 | "../get_next_line_utils_bonus.c", 44 | "bonus.c", 45 | "-o", 46 | "bonus.out", 47 | "-ldl" 48 | ], 49 | "options": { 50 | "cwd": "${fileDirname}" 51 | }, 52 | "problemMatcher": [ 53 | "$gcc" 54 | ], 55 | "group": "build", 56 | "detail": "compiler: /usr/bin/clang" 57 | } 58 | ] 59 | } -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:03:10 by badam #+# #+# */ 9 | /* Updated: 2019/06/17 04:48:51 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_sqrt(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("10:%d\n", ft_sqrt(100)); 20 | printf("6:%d\n", ft_sqrt(36)); 21 | printf("0:%d\n", ft_sqrt(37)); 22 | printf("100:%d\n", ft_sqrt(10000)); 23 | printf("0:%d\n", ft_sqrt(10001)); 24 | printf("2000:%d\n", ft_sqrt(4000000)); 25 | printf("0:%d\n", ft_sqrt(-36)); 26 | } 27 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/20 16:46:56 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | void ft_putnbr(int nb); 19 | 20 | int main() { 21 | ft_putnbr(0); 22 | write(1, "\n", 1); 23 | ft_putnbr(10); 24 | write(1, "\n", 1); 25 | ft_putnbr(-10); 26 | write(1, "\n", 1); 27 | ft_putnbr(INT_MAX); 28 | write(1, "\n", 1); 29 | ft_putnbr(INT_MIN); 30 | write(1, "\n", 1); 31 | } -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 13:25:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 13:34:24 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_div_mod(int a, int b, int *div, int *mod); 15 | 16 | int main(void) 17 | { 18 | int a; 19 | int b; 20 | int div; 21 | int mod; 22 | 23 | a = 123; 24 | b = 10; 25 | ft_div_mod(a, b, &div, &mod); 26 | printf("%d %d %d %d\n", a, b, div, mod); 27 | a = -123; 28 | b = 15; 29 | ft_div_mod(a, b, &div, &mod); 30 | printf("%d %d %d %d\n", a, b, div, mod); 31 | } 32 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 16:30:15 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_uppercase(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("\"ABZ\": %i\n", ft_str_is_uppercase("ABZ")); 20 | printf("\"AB@\": %i\n", ft_str_is_uppercase("AB@")); 21 | printf("\"AB[\": %i\n", ft_str_is_uppercase("AB[")); 22 | printf("\"\": %i\n", ft_str_is_uppercase("")); 23 | printf("\"DASFJET..\": %i\n", ft_str_is_uppercase("ADASFJET..")); 24 | } 25 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 18:07:47 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | char *ft_strupcase(char *str); 18 | 19 | int main(void) 20 | { 21 | char str[100] = "abcd-fsdAfddsSS"; 22 | char cpy[100]; 23 | char *ret; 24 | strcpy(cpy, str); 25 | 26 | printf("\"%s\": %s\n", str, ft_strupcase(cpy)); 27 | 28 | ret = ft_strupcase(cpy); 29 | printf("Same string returned? %i\n", ret == cpy); 30 | } 31 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_memcmp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_memcmp(int test_number, char *str1, char *str2, size_t n) 5 | { 6 | set_signature_tn(test_number, "ft_memcmp(%s, %s, %lu)", escape_str(str1), escape_str(str2), n); 7 | int res = ft_memcmp(str1, str2, n); 8 | int res_std = memcmp(str1, str2, n); 9 | 10 | return same_sign(res_std, res); 11 | } 12 | 13 | int test_memcmp(void) 14 | { 15 | int res = 1; 16 | 17 | res = single_test_memcmp(1, "teste", "teste", 0) && res; 18 | res = single_test_memcmp(2, "teste", "teste", 1) && res; 19 | res = single_test_memcmp(3, "teste", "teste", 5) && res; 20 | res = single_test_memcmp(4, "teste", "teste", 6) && res; 21 | res = single_test_memcmp(5, "teste", "testex", 6) && res; 22 | 23 | char s1[20] = "teste"; 24 | char s2[20] = "test"; 25 | res = single_test_memcmp(6, s1, s2, 10) && res; 26 | res = single_test_memcmp(7, s2, s1, 10) && res; 27 | 28 | strcpy(s1, "abcdef"); 29 | strcpy(s2, "abc\xfdxx"); 30 | res = single_test_memcmp(8, s1, s2, 5) && res; 31 | 32 | s1[3] = 0; 33 | s2[3] = 0; 34 | int other = single_test_memcmp(9, s1, s2, 7); 35 | if (!other && res) { 36 | fprintf(errors_file, BRED "You are stoping at the '\\0'\n" NC); 37 | res = 0; 38 | } 39 | return res; 40 | } 41 | 42 | int main() 43 | { 44 | handle_signals_with_time(); 45 | test(memcmp); 46 | } 47 | -------------------------------------------------------------------------------- /testers/pipex/Vfurname.py: -------------------------------------------------------------------------------- 1 | import re 2 | import subprocess 3 | 4 | from halo import Halo 5 | from utils.ExecutionContext import console 6 | from testers.BaseExecutor import BaseExecutor 7 | from utils.Utils import run_filter, show_errors_str 8 | 9 | test_line_regex = re.compile("^([^#]+)# (\d+):.*\[(\w+)\]$") 10 | 11 | 12 | class Vfurname(BaseExecutor): 13 | 14 | name = 'pipex-tester' 15 | folder = 'pipex-tester' 16 | git_url = 'https://github.com/vfurmane/pipex-tester' 17 | 18 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 19 | super().__init__(tests_dir, temp_dir, to_execute, missing) 20 | 21 | def execute(self): 22 | 23 | def line_handler(line): 24 | match = test_line_regex.match(line) 25 | if match: 26 | print(f"{match.group(1)}{int(match.group(2))}.{match.group(3)} ", end="") 27 | if '\033[32m' not in match.group(1): 28 | return True 29 | 30 | Halo(self.get_info_message("Executing tests")).info() 31 | has_errors, output = run_filter("./run.sh -lv", line_handler) 32 | if has_errors: 33 | show_errors_str(output, self.temp_dir, 20) 34 | outdir = (self.temp_dir / "outs").resolve() 35 | console.print(f"Output of the tests in: [purple]{outdir}[/purple]") 36 | console.print(f"Explanation of the files here: https://github.com/vfurmane/pipex-tester\n") 37 | return self.result(has_errors) 38 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 18:19:52 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | char *ft_strlowcase(char *str); 18 | 19 | int main(void) 20 | { 21 | char str[100] = "ABDSDF-sdfsdf,,sdfYU74rff;"; 22 | char cpy[100]; 23 | char *ret; 24 | strcpy(cpy, str); 25 | 26 | printf("\"%s\": %s\n", str, ft_strlowcase(cpy)); 27 | 28 | ret = ft_strlowcase(cpy); 29 | printf("Same string returned? %i\n", ret == cpy); 30 | } 31 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 16:37:31 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/06 18:10:03 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int nb); 18 | 19 | int main(void) 20 | { 21 | ft_putnbr(10); 22 | write(1, "\n", 1); 23 | ft_putnbr(-1); 24 | write(1, "\n", 1); 25 | ft_putnbr(0); 26 | write(1, "\n", 1); 27 | ft_putnbr(-123); 28 | write(1, "\n", 1); 29 | ft_putnbr(INT_MAX); 30 | write(1, "\n", 1); 31 | ft_putnbr(INT_MIN); 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:50:42 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_iterative_factorial(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_iterative_factorial(-10)); 20 | printf("0:%d\n", ft_iterative_factorial(-1)); 21 | printf("1:%d\n", ft_iterative_factorial(0)); 22 | printf("1:%d\n", ft_iterative_factorial(1)); 23 | printf("3628800:%d\n", ft_iterative_factorial(10)); 24 | printf("6:%d\n", ft_iterative_factorial(3)); 25 | } 26 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2021/12/21 08:48:30 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_recursive_factorial(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_recursive_factorial(-10)); 20 | printf("0:%d\n", ft_recursive_factorial(-1)); 21 | printf("1:%d\n", ft_recursive_factorial(0)); 22 | printf("1:%d\n", ft_recursive_factorial(1)); 23 | printf("3628800:%d\n", ft_recursive_factorial(10)); 24 | printf("6:%d\n", ft_recursive_factorial(3)); 25 | } 26 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:55:24 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_iterative_power(int nb, int power); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_iterative_power(1, -10)); 20 | printf("0:%d\n", ft_iterative_power(1, -1)); 21 | printf("1:%d\n", ft_iterative_power(10, 0)); 22 | printf("10:%d\n", ft_iterative_power(10, 1)); 23 | printf("100:%d\n", ft_iterative_power(10, 2)); 24 | printf("216:%d\n", ft_iterative_power(6, 3)); 25 | } 26 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:45:51 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 19:56:03 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_recursive_power(int nb, int power); 16 | 17 | int main(void) 18 | { 19 | printf("0:%d\n", ft_recursive_power(1, -10)); 20 | printf("0:%d\n", ft_recursive_power(1, -1)); 21 | printf("1:%d\n", ft_recursive_power(10, 0)); 22 | printf("10:%d\n", ft_recursive_power(10, 1)); 23 | printf("100:%d\n", ft_recursive_power(10, 2)); 24 | printf("216:%d\n", ft_recursive_power(6, 3)); 25 | } 26 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex11/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 20:37:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 21:36:23 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void ft_putstr_non_printable(char *str); 17 | 18 | int main(void) 19 | { 20 | char src[0xFF + 10]; 21 | int i; 22 | 23 | i = 1; 24 | while (i <= 0xFF) 25 | { 26 | src[i - 1] = i; 27 | i++; 28 | } 29 | src[i - 1] = 0; 30 | 31 | ft_putstr_non_printable("Coucou\ntu vas bien ?"); 32 | write(1, "\n", 1); 33 | ft_putstr_non_printable(src); 34 | write(1, "\n", 1); 35 | } 36 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 19:58:16 by badam #+# #+# */ 9 | /* Updated: 2021/12/22 12:25:23 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_fibonacci(int index); 16 | 17 | int main(void) 18 | { 19 | printf("-1:%d\n", ft_fibonacci(-20)); 20 | printf("-1:%d\n", ft_fibonacci(-1)); 21 | printf("0:%d\n", ft_fibonacci(0)); 22 | printf("1:%d\n", ft_fibonacci(1)); 23 | printf("1:%d\n", ft_fibonacci(2)); 24 | printf("2:%d\n", ft_fibonacci(3)); 25 | printf("55:%d\n", ft_fibonacci(10)); 26 | printf("6765:%d\n", ft_fibonacci(20)); 27 | } 28 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex12/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 20:37:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/16 12:56:24 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void *ft_print_memory(void *addr, unsigned int size); 17 | 18 | int main(void) 19 | { 20 | char src[0xFF + 10]; 21 | int i; 22 | 23 | i = 0; 24 | while (i <= 0xFF) 25 | { 26 | src[i] = i; 27 | i++; 28 | } 29 | src[i] = 0; 30 | 31 | i = 0; 32 | while (i < 30) 33 | { 34 | ft_print_memory((void *)src, i); 35 | i++; 36 | } 37 | 38 | ft_print_memory((void *)src, 0x101); 39 | } 40 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex09/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/16 16:33:06 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | char *ft_strcapitalize(char *str); 18 | 19 | int main(void) 20 | { 21 | char str[100] = "salut, comMent tu vas ? 42mots quarAnte-deux; cinquante+et+uN e.puntOs"; 22 | char cpy[100]; 23 | char *ret; 24 | strcpy(cpy, str); 25 | 26 | printf("%s\n", ft_strcapitalize(cpy)); 27 | 28 | ret = ft_strcapitalize(cpy); 29 | printf("Same string returned? %i\n", ret == cpy); 30 | } 31 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/20 22:12:14 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | int ft_atoi(char *str); 19 | 20 | int main() { 21 | printf("%i\n", ft_atoi("\t\n\v\f\r 23")); 22 | printf("%i\n", ft_atoi(" ------+++++---12341")); 23 | printf("%i\n", ft_atoi(" ------+++++---123413")); 24 | printf("%i\n", ft_atoi("00000000002147483647")); 25 | printf("%i\n", ft_atoi("-2147483648")); 26 | printf("%i\n", ft_atoi("a")); 27 | } -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/14 12:07:53 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_str_is_lowercase(char *str); 16 | 17 | int main(void) 18 | { 19 | printf("\"abz\": %i\n", ft_str_is_lowercase("abz")); 20 | printf("\"ab{\": %i\n", ft_str_is_lowercase("ab{")); 21 | printf("\"ab`\": %i\n", ft_str_is_lowercase("ab`")); 22 | printf("\"\": %i\n", ft_str_is_lowercase("")); 23 | printf("\"asdasda..\": %i\n", ft_str_is_lowercase("asdasda..")); 24 | printf("\"asdasAa\": %i\n", ft_str_is_lowercase("asdasAa")); 25 | } 26 | -------------------------------------------------------------------------------- /testers/cpiscine/CPiscine.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | 4 | from testers.BaseTester import BaseTester 5 | from testers.cpiscine.C00Tester import C00Tester 6 | from testers.cpiscine.C01Tester import C01Tester 7 | from testers.cpiscine.C02Tester import C02Tester 8 | from testers.cpiscine.C03Tester import C03Tester 9 | from testers.cpiscine.C04Tester import C04Tester 10 | from testers.cpiscine.C05Tester import C05Tester 11 | from utils.ExecutionContext import TestRunInfo 12 | 13 | logger = logging.getLogger('c selector') 14 | 15 | 16 | def has_file(ex_path, file): 17 | path = os.path.join(ex_path, file) 18 | logger.info(f"Testing path: {path}") 19 | return os.path.exists(path) 20 | 21 | 22 | class CPiscine(BaseTester): 23 | 24 | def __init__(self, info: TestRunInfo) -> None: 25 | super().__init__(info) 26 | 27 | @staticmethod 28 | def is_project(current_path): 29 | ex_path = (current_path / "ex00").resolve() 30 | logger.info(f"Testing path: {ex_path}") 31 | if os.path.exists(ex_path): 32 | if has_file(ex_path, "ft_putchar.c"): 33 | return C00Tester 34 | if has_file(ex_path, "ft_ft.c"): 35 | return C01Tester 36 | if has_file(ex_path, "ft_strcpy.c"): 37 | return C02Tester 38 | if has_file(ex_path, "ft_strcmp.c"): 39 | return C03Tester 40 | if has_file(ex_path, "ft_strlen.c"): 41 | return C04Tester 42 | if has_file(ex_path, "ft_iterative_factorial.c"): 43 | return C05Tester 44 | return False 45 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstclear.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | void free_str_ptr(void *str) 5 | { 6 | free(*((void **)str)); 7 | } 8 | 9 | char *node_ptr_to_str(t_list *node) 10 | { 11 | char *res = malloc(1000); 12 | if (node == NULL) 13 | sprintf(res, "(null)"); 14 | else { 15 | sprintf(res, "{node: ptr-> %s}", escape_str((char *)node->content)); 16 | } 17 | return res; 18 | } 19 | 20 | 21 | int test_single_lstclear(int test_number, t_list **list) 22 | { 23 | t_list *to_func = NULL; 24 | char *args[10]; 25 | int i = 0; 26 | 27 | char *s = list_to_str_fn(list, node_ptr_to_str); 28 | set_signature_tn(test_number, "ft_lstclear(%s, [(x) => free(" RED "*" CYN "x)])", s); free(s); 29 | 30 | while (*list != NULL) 31 | { 32 | args[i] = my_strdup((*list)->content); 33 | lstadd_back(&to_func, lstnew(args + i)); 34 | *list = (*list)->next; 35 | i++; 36 | } 37 | 38 | ft_lstclear(&to_func, free_str_ptr); 39 | int res = check_leaks(NULL); 40 | if (to_func != NULL) 41 | return error("The value stored in the lst should be NULL after the clear.\n"); 42 | return res; 43 | } 44 | 45 | int test_lstclear() 46 | { 47 | int res = test_single_lstclear(1, create_list(0)); 48 | res = test_single_lstclear(2, create_list(1, "hello!")) && res; 49 | res = test_single_lstclear(3, 50 | create_list(5, "um", "dois", "tres", "quatro", "cinco")) && res; 51 | 52 | return res; 53 | } 54 | 55 | int main() 56 | { 57 | handle_signals_with_time(); 58 | test(lstclear); 59 | } 60 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_atoi.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_atoi(int test_number, char *str) 5 | { 6 | set_signature_tn(test_number, "atoi(%s)", escape_str(str)); 7 | return same_value(atoi(str), ft_atoi(str)); 8 | } 9 | 10 | int test_atoi(void) 11 | { 12 | char buffer[200]; 13 | int res = 1; 14 | 15 | res = single_test_atoi(1, " \t\v\n\r\f123") && res; 16 | res = single_test_atoi(2, "0") && res; 17 | res = single_test_atoi(3, "-1000043") && res; 18 | res = single_test_atoi(4, 19 | "+0000000000000000000000000000000000000000000000000000123") && res; 20 | res = single_test_atoi(5, " 123") && res; 21 | res = single_test_atoi(6, "--123") && res; 22 | res = single_test_atoi(7, "-+123") && res; 23 | res = single_test_atoi(8, "+-123") && res; 24 | res = single_test_atoi(9, "++123") && res; 25 | res = single_test_atoi(10, "- 123") && res; 26 | res = single_test_atoi(11, "+ 123") && res; 27 | res = single_test_atoi(12, "+\n123") && res; 28 | res = single_test_atoi(13, "1209") && res; 29 | res = single_test_atoi(14, "12/3") && res; 30 | res = single_test_atoi(15, "12;3") && res; 31 | sprintf(buffer, "%i", INT_MAX); 32 | res = single_test_atoi(16, buffer) && res; 33 | sprintf(buffer, "%i", INT_MIN); 34 | res = single_test_atoi(17, buffer) && res; 35 | 36 | for (int i = 0; i <= 0xFF; i++) { 37 | sprintf(buffer, "%c %i", i, i + 1); 38 | res = single_test_atoi(18 + i, buffer) && res; 39 | } 40 | 41 | return res; 42 | } 43 | 44 | int main() 45 | { 46 | handle_signals_with_time(); 47 | test(atoi); 48 | } 49 | -------------------------------------------------------------------------------- /tests/cpiscine/c00/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/06 16:37:31 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/16 20:55:56 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void ft_print_combn(int n); 17 | 18 | int main(void) 19 | { 20 | ft_print_combn(1); 21 | write(1, "\n", 1); 22 | ft_print_combn(2); 23 | write(1, "\n", 1); 24 | ft_print_combn(3); 25 | write(1, "\n", 1); 26 | ft_print_combn(4); 27 | write(1, "\n", 1); 28 | ft_print_combn(5); 29 | write(1, "\n", 1); 30 | ft_print_combn(6); 31 | write(1, "\n", 1); 32 | ft_print_combn(7); 33 | write(1, "\n", 1); 34 | ft_print_combn(8); 35 | write(1, "\n", 1); 36 | ft_print_combn(9); 37 | write(1, "\n", 1); 38 | ft_print_combn(10); 39 | return (0); 40 | } 41 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 15:19:05 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 15:19:45 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | void ft_rev_int_tab(int *tab, int size); 16 | 17 | void print_array(int *arr, int size) 18 | { 19 | int i; 20 | 21 | i = 0; 22 | while (i < size) 23 | printf("%d ", arr[i++]); 24 | printf("\n"); 25 | } 26 | 27 | int main(void) 28 | { 29 | int empty[0]; 30 | int test_even[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 31 | int test_odd[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; 32 | 33 | ft_rev_int_tab(empty, 0); 34 | ft_rev_int_tab(test_even, 10); 35 | ft_rev_int_tab(test_odd, 11); 36 | print_array(empty, 0); 37 | print_array(test_even, 10); 38 | print_array(test_odd, 11); 39 | } -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 17:17:37 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strcmp(char *s1, char *s2); 17 | 18 | int main() { 19 | char *str0 = ""; 20 | printf("std: %i, yours: %i\n", strcmp(str0, "a"), ft_strcmp(str0, "a")); 21 | 22 | char *str1 = (char *)"abcadef"; 23 | char *str2 = (char *)"abcadef"; 24 | printf("std: %i, yours: %i\n", strcmp(str1, str2), ft_strcmp(str1, str2)); 25 | 26 | str1 = "abcadef"; 27 | str2 = "abcad"; 28 | printf("std: %i, yours: %i\n", strcmp(str1, str2), ft_strcmp(str1, str2)); 29 | 30 | str1 = "abcad"; 31 | str2 = "abcadtg"; 32 | printf("std: %i, yours: %i\n", strcmp(str1, str2), ft_strcmp(str1, str2)); 33 | } -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 12:40:24 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/08 13:12:38 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | 14 | void ft_ultimate_ft(int *********ptr); 15 | 16 | int main(void) 17 | { 18 | int a; 19 | int *ptra1; 20 | int **ptra2; 21 | int ***ptra3; 22 | int ****ptra4; 23 | int *****ptra5; 24 | int ******ptra6; 25 | int *******ptra7; 26 | int ********ptra8; 27 | int *********ptra9; 28 | 29 | a = 567; 30 | ptra1 = &a; 31 | ptra2 = &ptra1; 32 | ptra3 = &ptra2; 33 | ptra4 = &ptra3; 34 | ptra5 = &ptra4; 35 | ptra6 = &ptra5; 36 | ptra7 = &ptra6; 37 | ptra8 = &ptra7; 38 | ptra9 = &ptra8; 39 | ft_ultimate_ft(ptra9); 40 | printf("%d\n", a); 41 | a = 234; 42 | printf("%d\n", a); 43 | ft_ultimate_ft(ptra9); 44 | printf("%d", a); 45 | } 46 | -------------------------------------------------------------------------------- /testers/pipex/Medic.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | import shutil 4 | 5 | from halo import Halo 6 | from testers.BaseExecutor import BaseExecutor 7 | from utils.ExecutionContext import console 8 | 9 | logger = logging.getLogger("px-medic") 10 | 11 | test_line_regex = re.compile("^([^#]+)# (\d+):.*\[(\w+)\]$") 12 | 13 | 14 | class Medic(BaseExecutor): 15 | 16 | name = 'pipexMedic' 17 | folder = 'pipexMedic' 18 | git_url = 'https://github.com/gmarcha/pipexMedic' 19 | line_regex = re.compile(r"^()(1\..+)$") 20 | test_regex = re.compile(r"(\d+)\. ([^ ]+)") 21 | 22 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 23 | super().__init__(tests_dir, temp_dir, to_execute, missing) 24 | 25 | def execute(self): 26 | Halo(self.get_info_message("Executing tests")).info() 27 | m_errors, b_errors = False, False 28 | if self.exec_mandatory: 29 | self.execute_in_project_dir("make all") 30 | output = self.execute_command("bash test.sh m") 31 | print() 32 | m_errors = self.check_errors(output) 33 | if m_errors: 34 | shutil.copy("tester.log", "mandatory.log") 35 | 36 | if self.exec_bonus: 37 | console.print("[Bonus]", style="purple") 38 | self.execute_in_project_dir("make fclean bonus") 39 | output = self.execute_command("bash test.sh a") 40 | print() 41 | b_errors = self.check_errors(output) 42 | if b_errors: 43 | shutil.copy("tester.log", "bonus.log") 44 | 45 | if m_errors: 46 | self.show_errors_file("mandatory.log", "mandatory.log") 47 | if b_errors: 48 | self.show_errors_file("bonus.log", "bonus.log") 49 | return self.result(m_errors or b_errors) 50 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 21:49:12 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 17:04:04 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_str_is_printable(char *str); 17 | 18 | int main(void) 19 | { 20 | int c; 21 | int i = 0; 22 | char str[150]; 23 | 24 | for (c = 1; c <= 127; ++c) 25 | if (isprint(c) != 0) 26 | str[i++] = c; 27 | 28 | printf("\"\": %i\n", ft_str_is_printable("")); 29 | printf("\"%s\": %i\n", str, ft_str_is_printable(str)); 30 | printf("with a tab: %i\n", ft_str_is_printable("fs\ts")); 31 | 32 | str[0] = 31; 33 | str[10] = '\0'; 34 | printf("With the character just before: %i\n", ft_str_is_printable(str)); 35 | 36 | str[0] = 127; 37 | str[10] = '\0'; 38 | printf("With the character just after: %i\n", ft_str_is_printable(str)); 39 | } 40 | -------------------------------------------------------------------------------- /testers/get_next_line/Tripouille.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | 4 | from testers.BaseExecutor import BaseExecutor 5 | from utils.ExecutionContext import get_timeout 6 | from utils.TerminalColors import TC 7 | 8 | logger = logging.getLogger('gnl-trip') 9 | 10 | 11 | class Tripouille(BaseExecutor): 12 | 13 | name = 'gnlTester' 14 | folder = 'gnlTester' 15 | git_url = 'https://github.com/Tripouille/gnlTester' 16 | line_regex = re.compile(r"^([^:]+):(.+)$") 17 | test_regex = re.compile(r"(\d+|LEAKS).([^ ]+)") 18 | 19 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 20 | super().__init__(tests_dir, temp_dir, to_execute, missing) 21 | 22 | def execute(self): 23 | 24 | def handle_output(output, execute=True): 25 | if not execute or not output: 26 | return [] 27 | lines = output.splitlines() 28 | if lines[1].startswith("../"): 29 | raise Exception(f"{TC.B_RED}Problem compiling tests.{TC.NC}") 30 | errors = self.check_errors(output) 31 | return errors 32 | 33 | def execute_make(command, execute=True, silent=False): 34 | if execute: 35 | return self.run_tests(command, not silent) 36 | 37 | timeout = f"TIMEOUT_US={get_timeout() * 1_000_000}" 38 | output = execute_make(f"make {timeout} m", self.exec_mandatory) 39 | output_bonus = execute_make(f"make {timeout} b", self.exec_bonus, True) 40 | print() 41 | errors = handle_output(output, self.exec_mandatory) 42 | 43 | all_errors = set(errors).union(handle_output(output_bonus, self.exec_bonus)) 44 | self.show_test_files(all_errors, ["multiple fd"], "tests/mandatory.cpp", "tests/bonus.cpp") 45 | return [self.name] if all_errors else [] 46 | -------------------------------------------------------------------------------- /tests/minitalk/fsoares/middleman.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int server_pid; 7 | int signals_val[1000000]; 8 | int signals_source[1000000]; 9 | int signal_pos = 0; 10 | FILE *outfile; 11 | 12 | void sighandler(int signum, int c_pid) 13 | { 14 | static int client_pid = -1; 15 | if (signum == 2 && c_pid != server_pid && c_pid != client_pid) 16 | { 17 | for (size_t i = 0; i < signal_pos; i++) 18 | printf("%i from %i\n", signals_val[i], signals_source[i]); 19 | printf("\n=====\n"); 20 | exit(0); 21 | } 22 | 23 | signals_val[signal_pos] = signum; 24 | signals_source[signal_pos++] = c_pid; 25 | if (c_pid != server_pid && client_pid == -1) 26 | { 27 | fprintf(outfile, "setting client to: %i\n", c_pid); 28 | client_pid = c_pid; 29 | } 30 | if (c_pid == client_pid) { 31 | //fprintf(outfile, "sending %i to server %i\n", signum, server_pid); 32 | kill(server_pid, signum); 33 | } 34 | else if (c_pid == server_pid) { 35 | //fprintf(outfile, "sending %i to client %i\n", signum, client_pid); 36 | kill(client_pid, signum); 37 | } 38 | } 39 | 40 | void get_pid(int signum, siginfo_t *info, void *context) 41 | { 42 | if (context) 43 | sighandler(signum, info->si_pid); 44 | } 45 | 46 | int main(int argc, char *argv[]) 47 | { 48 | struct sigaction sa; 49 | 50 | outfile = fopen("signals_middle.log", "w"); 51 | printf("__PID: %i\n-----\n", getpid()); 52 | server_pid = atoi(argv[1]); 53 | sa.sa_flags = SA_SIGINFO; 54 | sa.sa_sigaction = get_pid; 55 | for (int sig = 1; sig < NSIG; sig++) 56 | sigaction(sig, &sa, NULL); 57 | while (1) 58 | sleep(1); 59 | return (0); 60 | } -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstdelone.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | 5 | void free_str(void *str) 6 | { 7 | free(str); 8 | } 9 | 10 | void free_str_ptr(void *str) 11 | { 12 | free(*((void **)str)); 13 | } 14 | 15 | int test_lstdelone() 16 | { 17 | char *elem_str = node_to_str(lstnew("add")); 18 | set_signature_tn(1, "ft_lstdelone(%s, [(x) => free(x)])", elem_str); 19 | free(elem_str); 20 | 21 | reset_malloc_mock(); 22 | char *s = malloc(6); 23 | strcpy(s, "teste"); 24 | t_list *l = lstnew(s); 25 | ft_lstdelone(l, free_str); 26 | int res = check_leaks(NULL); 27 | if (!res) 28 | { 29 | fseek(errors_file, -1, SEEK_CUR); 30 | fprintf(errors_file, "" BMAG "del" NC " should be used on " BLU "content" NC \ 31 | ", and " BMAG "free" NC " on the " BLU "lst" NC "\n\n"); 32 | } 33 | 34 | // 2 35 | char *warn = (NC "Do not use " BMAG "del" NC " on the " BLU "lst" NC ". Use " BMAG "free" NC " instead"); 36 | set_signature_tn(2, "ft_lstdelone({node: content->ptr->\"test\"}, [(x) => free(" RED "*" CYN "x)]): %s", warn); 37 | reset_malloc_mock(); 38 | s = malloc(5); 39 | strcpy(s, "test"); 40 | l = lstnew(&s); 41 | ft_lstdelone(l, free_str_ptr); 42 | res = check_leaks(NULL) && res; 43 | 44 | // 3 45 | s = malloc(5); 46 | strcpy(s, "test"); 47 | t_list **list = create_list(2, s, "second"); 48 | t_list *keep = (*list)->next; 49 | char *lst_str = list_to_str(list); 50 | set_signature_tn(3, "ft_lstdelone(%s, [(x) => free(x)]): " NC "The second node should not be freed", lst_str); 51 | reset_malloc_mock(); 52 | ft_lstdelone(*list, free_str); 53 | free(keep); 54 | res = check_leaks(NULL) && res; 55 | 56 | return res; 57 | } 58 | 59 | int main() 60 | { 61 | handle_signals_with_time(); 62 | test(lstdelone); 63 | } 64 | -------------------------------------------------------------------------------- /utils/LeaksCheck.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import re 3 | import subprocess 4 | import threading 5 | from time import sleep 6 | from utils.ExecutionContext import console 7 | 8 | logger = logging.getLogger("leak-check") 9 | 10 | leaks_regex = re.compile(".* (\d+) leak(?:s)? for (\d+) total.*") 11 | 12 | 13 | class LeakException(Exception): 14 | pass 15 | 16 | 17 | class LeakChecker(threading.Thread): 18 | 19 | def __init__(self, command, timeout=1, input=None): 20 | self.stdout = None 21 | self.stderr = None 22 | self.pid = None 23 | self.command = command 24 | self.return_code = None 25 | self.input = input 26 | self.timeout = timeout 27 | threading.Thread.__init__(self) 28 | 29 | def run(self): 30 | proc = subprocess.Popen(("leaks -q -atExit -- " + self.command).split(), 31 | errors="backslashreplace", 32 | stdout=subprocess.PIPE, 33 | stdin=subprocess.PIPE, 34 | stderr=subprocess.STDOUT) 35 | self.pid = str(proc.pid) 36 | self.stdout = "" 37 | if self.input: 38 | lines = self.input.splitlines(True) 39 | for line in lines: 40 | proc.stdin.write(line) 41 | proc.stdin.close() 42 | while True: 43 | line = proc.stdout.readline() 44 | self.stdout += line 45 | 46 | 47 | def has_leaks(command, timeout=1.5, input=None): 48 | checker = LeakChecker(command, timeout, input=input) 49 | checker.daemon = True 50 | checker.start() 51 | sleep(1) 52 | if not checker.stdout: 53 | console.print("\nLeak check was not executed, do it manually\n", style="b yellow") 54 | raise LeakException() 55 | leaks = next(line for line in checker.stdout.splitlines() if leaks_regex.match(line)) 56 | match = leaks_regex.match(leaks) 57 | if match.group(1) != "0": 58 | return checker.stdout 59 | return False 60 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex06/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:36:43 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 20:43:20 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_is_prime(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_is_prime(-1) == 0 ? "OK" : "Fail", 21 | ft_is_prime(-3) == 0 ? "OK" : "Fail", 22 | ft_is_prime(0) == 0 ? "OK" : "Fail", 23 | ft_is_prime(1) == 0 ? "OK" : "Fail", 24 | ft_is_prime(2) == 1 ? "OK" : "Fail", 25 | ft_is_prime(3) == 1 ? "OK" : "Fail", 26 | ft_is_prime(4) == 0 ? "OK" : "Fail", 27 | ft_is_prime(5) == 1 ? "OK" : "Fail", 28 | ft_is_prime(6) == 0 ? "OK" : "Fail", 29 | ft_is_prime(7) == 1 ? "OK" : "Fail", 30 | ft_is_prime(10) == 0 ? "OK" : "Fail", 31 | ft_is_prime(11) == 1 ? "OK" : "Fail", 32 | ft_is_prime(13) == 1 ? "OK" : "Fail", 33 | ft_is_prime(19) == 1 ? "OK" : "Fail", 34 | ft_is_prime(20) == 0 ? "OK" : "Fail" 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 14:45:28 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 17:17:58 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_strncmp(char *s1, char *s2, unsigned int n); 17 | 18 | int main() { 19 | char *str1 = (char *)"xxxxxx"; 20 | char *str2 = (char *)"yyyyyy"; 21 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 20), ft_strncmp(str1, str2, 20)); 22 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 0), ft_strncmp(str1, str2, 0)); 23 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 1), ft_strncmp(str1, str2, 1)); 24 | 25 | str1 = "abcadef"; 26 | str2 = "abcad"; 27 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 5), ft_strncmp(str1, str2, 5)); 28 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 6), ft_strncmp(str1, str2, 6)); 29 | 30 | str1 = "abcad"; 31 | str2 = "abcadtg"; 32 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 5), ft_strncmp(str1, str2, 5)); 33 | printf("std: %i, yours: %i\n", strncmp(str1, str2, 6), ft_strncmp(str1, str2, 6)); 34 | } 35 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_substr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int test_single_substr(int test_number, char *str, unsigned int start, size_t size, char *expected) 5 | { 6 | set_signature_tn(test_number, "ft_substr(\"%s\", %u, %zu)", str, start, size); 7 | check_alloc_str_return(ft_substr(str, start, size), expected); 8 | } 9 | 10 | int test_substr() 11 | { 12 | int res = 1; 13 | res = test_single_substr(1, "", 0, 0, "") && res; 14 | res = test_single_substr(2, "", 0, 1, "") && res; 15 | res = test_single_substr(3, "", 1, 1, "") && res; 16 | res = test_single_substr(4, "hola", -1, 0, "") && res; 17 | res = test_single_substr(5, "hola", 0, -1, "hola") && res; 18 | res = test_single_substr(6, "hola", -1, -1, "") && res; 19 | res = test_single_substr(7, "hola", 0, 0, "") && res; 20 | res = test_single_substr(8, "hola", 0, 1, "h") && res; 21 | res = test_single_substr(9, "hola", 0, 3, "hol") && res; 22 | res = test_single_substr(10, "hola", 0, 4, "hola") && res; 23 | res = test_single_substr(11, "hola", 0, 5, "hola") && res; 24 | res = test_single_substr(12, "hola", 2, 0, "") && res; 25 | res = test_single_substr(13, "hola", 2, 1, "l") && res; 26 | res = test_single_substr(14, "hola", 2, 2, "la") && res; 27 | res = test_single_substr(15, "hola", 2, 3, "la") && res; 28 | res = test_single_substr(16, "hola", 2, 30, "la") && res; 29 | res = test_single_substr(17, "hola", 3, 0, "") && res; 30 | res = test_single_substr(18, "hola", 3, 1, "a") && res; 31 | res = test_single_substr(19, "hola", 3, 2, "a") && res; 32 | res = test_single_substr(20, "hola", 4, 0, "") && res; 33 | res = test_single_substr(21, "hola", 4, 1, "") && res; 34 | res = test_single_substr(22, "hola", 4, 20, "") && res; 35 | res = test_single_substr(23, "hola", 5, 2, "") && res; 36 | 37 | return res; 38 | } 39 | 40 | int main() 41 | { 42 | handle_signals_with_time(); 43 | test(substr); 44 | } 45 | -------------------------------------------------------------------------------- /tests/cpiscine/c05/ex07/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: badam +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2019/06/15 20:36:43 by badam #+# #+# */ 9 | /* Updated: 2019/06/15 20:51:23 by badam ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | int ft_find_next_prime(int nb); 16 | 17 | int main(void) 18 | { 19 | printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", 20 | ft_find_next_prime(-1) == 2 ? "OK" : "Fail", 21 | ft_find_next_prime(-3) == 2 ? "OK" : "Fail", 22 | ft_find_next_prime(0) == 2 ? "OK" : "Fail", 23 | ft_find_next_prime(1) == 2 ? "OK" : "Fail", 24 | ft_find_next_prime(2) == 2 ? "OK" : "Fail", 25 | ft_find_next_prime(3) == 3 ? "OK" : "Fail", 26 | ft_find_next_prime(4) == 5 ? "OK" : "Fail", 27 | ft_find_next_prime(5) == 5 ? "OK" : "Fail", 28 | ft_find_next_prime(6) == 7 ? "OK" : "Fail", 29 | ft_find_next_prime(7) == 7 ? "OK" : "Fail", 30 | ft_find_next_prime(10) == 11 ? "OK" : "Fail", 31 | ft_find_next_prime(11) == 11 ? "OK" : "Fail", 32 | ft_find_next_prime(13) == 13 ? "OK" : "Fail", 33 | ft_find_next_prime(19) == 19 ? "OK" : "Fail", 34 | ft_find_next_prime(20) == 23 ? "OK" : "Fail" 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "expected": "text", 4 | "*.refactor": "restructuredtext", 5 | "unistd.h": "c", 6 | "stdint.h": "c", 7 | "signal.h": "c", 8 | "cdefs.h": "c", 9 | "csignal": "c", 10 | "libft.h": "c", 11 | "utils.h": "c", 12 | "__split_buffer": "c", 13 | "bitset": "c", 14 | "initializer_list": "c", 15 | "iterator": "c", 16 | "string": "c", 17 | "string_view": "c", 18 | "utility": "c", 19 | "vector": "c", 20 | "sstream": "c", 21 | "dlfcn.h": "c", 22 | "features.h": "c", 23 | "*.tcc": "cpp", 24 | "cstdlib": "cpp", 25 | "memory": "cpp", 26 | "new": "cpp", 27 | "exception": "c", 28 | "functional": "c", 29 | "algorithm": "c", 30 | "random": "c", 31 | "fstream": "c", 32 | "istream": "c", 33 | "numeric": "c", 34 | "ostream": "c", 35 | "streambuf": "c", 36 | "cmath": "c", 37 | "type_traits": "c", 38 | "typeinfo": "c", 39 | "stdbool.h": "c", 40 | "__locale": "c", 41 | "complex": "c", 42 | "__config": "c", 43 | "color.h": "c", 44 | "cstdio": "cpp", 45 | "__hash_table": "c", 46 | "__node_handle": "c", 47 | "my_utils.h": "c", 48 | "system_error": "cpp", 49 | "execinfo.h": "c", 50 | "pf_utils.h": "c", 51 | "ft_printf.h": "c", 52 | "filesystem": "c", 53 | "get_next_line_bonus.h": "c", 54 | "file_utils.h": "c" 55 | }, 56 | "python.linting.enabled": true, 57 | "python.linting.pylintPath": "pylint", 58 | "python.formatting.provider": "yapf", 59 | "python.formatting.yapfArgs": [ 60 | "--style={based_on_style: google, column_limit: 120, indent_width: 4, use_tabs: true}" 61 | ], 62 | "cSpell.words": [ 63 | "Alelievr", 64 | "Cacharle", 65 | "cafile", 66 | "certifi", 67 | "cpiscine", 68 | "francinette", 69 | "getpid", 70 | "infile", 71 | "inplace", 72 | "libftprintf", 73 | "lldb", 74 | "norminette", 75 | "pexpect", 76 | "Popen", 77 | "rglob", 78 | "Tripouille", 79 | "Vfurname" 80 | ] 81 | } -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strncmp.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strncmp(int test_number, char *str1, char *str2, size_t n) 5 | { 6 | set_signature_tn(test_number, "ft_strncmp(%s, %s, %lu)", escape_str(str1), escape_str(str2), n); 7 | int res = ft_strncmp(str1, str2, n); 8 | int res_std = strncmp(str1, str2, n); 9 | 10 | return same_sign(res_std, res); 11 | } 12 | 13 | int test_strncmp(void) 14 | { 15 | int res = 1; 16 | 17 | 18 | res = single_test_strncmp(1, "", "", 0) && res; 19 | res = single_test_strncmp(2, "", "", 1) && res; 20 | res = single_test_strncmp(3, "", "", 2) && res; 21 | res = single_test_strncmp(4, "test", "", 0) && res; 22 | res = single_test_strncmp(5, "test", "", 1) && res; 23 | res = single_test_strncmp(6, "test", "", 2) && res; 24 | res = single_test_strncmp(7, "", "test", 0) && res; 25 | res = single_test_strncmp(8, "", "test", 1) && res; 26 | res = single_test_strncmp(9, "", "test", 2) && res; 27 | res = single_test_strncmp(10, "teste", "teste", 0) && res; 28 | res = single_test_strncmp(12, "teste", "teste", 1) && res; 29 | res = single_test_strncmp(13, "teste", "teste", 5) && res; 30 | res = single_test_strncmp(14, "teste", "teste", 6) && res; 31 | res = single_test_strncmp(15, "teste", "teste", 7) && res; 32 | res = single_test_strncmp(16, "teste", "testex", 6) && res; 33 | res = single_test_strncmp(17, "teste", "test", 10) && res; 34 | res = single_test_strncmp(18, "test", "teste", 10) && res; 35 | 36 | unsigned char s1[10] = "abcdef"; 37 | unsigned char s2[10] = "abc\xfdxx"; 38 | res = single_test_strncmp(19, (char *)s1, (char *)s2, 5) && res; 39 | 40 | s1[3] = 0; 41 | s2[3] = 0; 42 | int other = single_test_strncmp(20, (char *)s1, (char *)s2, 7); 43 | if (!other) { 44 | fprintf(errors_file, BRED "You are not stoping at the '\\0'\n" NC); 45 | res = 0; 46 | } 47 | return res; 48 | } 49 | 50 | int main() 51 | { 52 | handle_signals_with_time(); 53 | test(strncmp); 54 | } 55 | -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/20 20:06:11 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 07:16:37 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void ft_putnbr_base(int nbr, char *base); 17 | 18 | int main(void) 19 | { 20 | write(1, "42:", 3); 21 | ft_putnbr_base(42, "0123456789"); 22 | write(1, "\n2a:", 4); 23 | ft_putnbr_base(42, "0123456789abcdef"); 24 | write(1, "\n-2a:", 5); 25 | ft_putnbr_base(-42, "0123456789abcdef"); 26 | write(1, "\n0:", 3); 27 | ft_putnbr_base(0, "0123456789abcdef"); 28 | write(1, "\nINT_MAX:", 9); 29 | ft_putnbr_base(INT_MAX, "0123456789abcdef"); 30 | write(1, "\nINT_MAX:", 9); 31 | ft_putnbr_base(INT_MAX, "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210"); 32 | write(1, "\nINT_MIN:", 9); 33 | ft_putnbr_base(INT_MIN, "0123456789abcdef"); 34 | write(1, "\n-2143247366 : ", 15); 35 | ft_putnbr_base(INT_MIN + 4236282, "'~"); 36 | write(1, "\n-1:", 4); 37 | ft_putnbr_base(-1, "0123456789abcdef"); 38 | write(1, "\n:", 2); 39 | ft_putnbr_base(42, ""); 40 | write(1, "\n:", 2); 41 | ft_putnbr_base(42, "0"); 42 | write(1, "\n:", 2); 43 | ft_putnbr_base(42, "+-0123456789abcdef"); 44 | write(1, "\n:", 2); 45 | ft_putnbr_base(42, "\v0123456789abcdef"); 46 | } -------------------------------------------------------------------------------- /tests/get_next_line/fsoares/Makefile: -------------------------------------------------------------------------------- 1 | TIMEOUT = 10 2 | CFLAGS = -g -fsanitize=address -Wall -Wextra -Werror 3 | STRICT = 4 | UTILS = utils/malloc_mock.c utils/utils.c file_utils.c 5 | TEST_FILES = ../get_next_line.c ../get_next_line_utils.c 6 | BONUS_FILES = ../get_next_line_bonus.c ../get_next_line_utils_bonus.c 7 | TIMEOUT_ARG = -D TIMEOUT=$(TIMEOUT) 8 | 9 | ifdef EXEC_STRICT 10 | STRICT = -D STRICT_MEM 11 | endif 12 | 13 | # SDK headers shipping w/Xcode 14.1 (22/11/01) 14 | # and later deprecate some functions used here 15 | CFLAGS += -Wno-deprecated-declarations 16 | 17 | UNAME = $(shell uname -s) 18 | ifeq ($(UNAME), Linux) 19 | CFLAGS = -g -Wall -Wextra -Werror 20 | endif 21 | 22 | mandatory: 23 | -@clang $(CFLAGS) -D BUFFER_SIZE=1 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(TEST_FILES) -ldl -o test1.out && ./test1.out < lines_around_10.txt 24 | -@clang $(CFLAGS) -D BUFFER_SIZE=10 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(TEST_FILES) -ldl -o test2.out && ./test2.out < lines_around_10.txt 25 | -@clang $(CFLAGS) -D BUFFER_SIZE=1000000 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(TEST_FILES) -ldl -o test3.out && ./test3.out < lines_around_10.txt 26 | 27 | bonus: 28 | @tput setaf 3 && /bin/echo BONUS! 29 | -@clang $(CFLAGS) -D BUFFER_SIZE=1 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(BONUS_FILES) -ldl -o test4.out && ./test4.out < lines_around_10.txt && rm -f test.out 30 | -@clang $(CFLAGS) -D BUFFER_SIZE=10 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(BONUS_FILES) -ldl -o test5.out && ./test5.out < lines_around_10.txt && rm -f test.out 31 | -@clang $(CFLAGS) -D BUFFER_SIZE=1000000 $(TIMEOUT_ARG) $(STRICT) tester.c $(UTILS) $(BONUS_FILES) -ldl -o test6.out && ./test6.out < lines_around_10.txt && rm -f test.out 32 | 33 | -@clang $(CFLAGS) -D BUFFER_SIZE=1 $(TIMEOUT_ARG) $(STRICT) bonus.c $(UTILS) $(BONUS_FILES) -ldl -o test7.out && ./test7.out && rm -f test.out 34 | -@clang $(CFLAGS) -D BUFFER_SIZE=10 $(TIMEOUT_ARG) $(STRICT) bonus.c $(UTILS) $(BONUS_FILES) -ldl -o test8.out && ./test8.out && rm -f test.out 35 | -@clang $(CFLAGS) -D BUFFER_SIZE=1000000 $(TIMEOUT_ARG) $(STRICT) bonus.c $(UTILS) $(BONUS_FILES) -ldl -o test9.out && ./test9.out && rm -f test.out 36 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstmap.c: -------------------------------------------------------------------------------- 1 | 2 | #include "list_utils.h" 3 | 4 | void *map_length(void *s) 5 | { 6 | char *str = malloc(30); 7 | if (str != NULL) 8 | sprintf(str, "__%lX", strlen((char *)s)); 9 | return str; 10 | } 11 | 12 | void delete(void *content) 13 | { 14 | char *str = (char *)content; 15 | if (str == NULL) 16 | return; 17 | if (str[0] != '_' || str[1] != '_') 18 | error("You are not using the " BMAG "del" NC " function correctly\n"); 19 | free(content); 20 | } 21 | 22 | int test_single_lstmap(int test_number, t_list **initial, t_list **expected) 23 | { 24 | char *list_str = list_to_str(initial); 25 | set_signature_tn(test_number, "ft_lstmap(%s, [s => __strlen(s)], [x => free(x)])", list_str); free(list_str); 26 | 27 | t_list *res = ft_lstmap(*initial, map_length, delete); 28 | int result = same_list(expected, &res); 29 | lstclear(&res, free); 30 | result = check_leaks(NULL) && result; 31 | 32 | #ifdef STRICT_MEM 33 | reset_malloc_mock(); 34 | ft_lstmap(*initial, map_length, delete); 35 | int malloc_calls = reset_malloc_mock(); 36 | int no_leaks; 37 | for (int i = 0; i < malloc_calls; i++) 38 | { 39 | sprintf(signature + g_offset, NC " NULL check for %ith malloc", i); 40 | malloc_set_null(i); 41 | t_list *res = ft_lstmap(*initial, map_length, delete); 42 | lstclear(&res, delete); 43 | no_leaks = check_leaks(NULL); 44 | if (!no_leaks) { 45 | fseek(errors_file, -1, SEEK_CUR); 46 | fprintf(errors_file, "Most likely you are not calling " BMAG "del" NC \ 47 | " on the content when a new list node allocation fails.\n\n"); 48 | } 49 | result = no_leaks && result; 50 | if (res != NULL) 51 | result = error("Should return NULL\n"); 52 | } 53 | #endif 54 | return result; 55 | } 56 | 57 | int test_lstmap() 58 | { 59 | int res = test_single_lstmap(1, create_list(0), create_list(0)); 60 | res = test_single_lstmap(2, create_list(1, "hello!"), create_list(1, "__6")); 61 | res = test_single_lstmap(3, 62 | create_list(5, "one", "two", "three", "four", "five"), 63 | create_list(5, "__3", "__3", "__5", "__4", "__4")); 64 | return res; 65 | } 66 | 67 | int main() 68 | { 69 | handle_signals_with_time(); 70 | test(lstmap); 71 | } 72 | -------------------------------------------------------------------------------- /tests/cpiscine/c01/ex08/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 15:11:34 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/17 13:18:15 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void ft_sort_int_tab(int *tab, int size); 17 | 18 | void ft_swap(int *a, int *b) 19 | { 20 | int temp; 21 | 22 | temp = *a; 23 | *a = *b; 24 | *b = temp; 25 | } 26 | 27 | void print_array(int *arr, int size) 28 | { 29 | int i; 30 | 31 | i = 0; 32 | while (i < size) 33 | printf("%d ", arr[i++]); 34 | printf("\n"); 35 | } 36 | 37 | void shuffle_array(int *arr, int size) 38 | { 39 | int counter; 40 | 41 | counter = 0; 42 | while (counter < size * 5) 43 | { 44 | ft_swap(&arr[rand() % size], &arr[rand() % size]); 45 | counter++; 46 | } 47 | } 48 | 49 | void populate_array(int *arr, int size) 50 | { 51 | int i; 52 | 53 | i = 0; 54 | while (i < size) 55 | { 56 | arr[i] = i + 1; 57 | i++; 58 | } 59 | shuffle_array(arr, size); 60 | } 61 | 62 | int main(void) 63 | { 64 | int empty[0]; 65 | int test_even[10]; 66 | int test_odd[11]; 67 | int test_lots[123]; 68 | 69 | populate_array(test_even, 10); 70 | populate_array(test_odd, 11); 71 | populate_array(test_lots, 123); 72 | ft_sort_int_tab(empty, 0); 73 | ft_sort_int_tab(test_even, 10); 74 | ft_sort_int_tab(test_odd, 11); 75 | ft_sort_int_tab(test_lots, 123); 76 | print_array(empty, 0); 77 | print_array(test_even, 10); 78 | print_array(test_odd, 11); 79 | print_array(test_lots, 123); 80 | } 81 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_lstadd_front.c: -------------------------------------------------------------------------------- 1 | #include "list_utils.h" 2 | 3 | int test_single_lstadd_front(int test_number, t_list **list, t_list *to_add, t_list **expected) 4 | { 5 | char *list_str = list_to_str(list); 6 | char *to_add_str = node_to_str(to_add); 7 | set_signature_tn(test_number, "ft_lstadd_front(%s, %s)", list_str, to_add_str); 8 | free(list_str); free(to_add_str); 9 | 10 | ft_lstadd_front(list, to_add); 11 | int result = same_list(expected, list); 12 | 13 | null_null_check(ft_lstadd_front(list, to_add), result); 14 | return result; 15 | } 16 | 17 | int test_single_lstadd_front_multiple_ok( 18 | int test_number, t_list **list, t_list *to_add, t_list **expected, t_list **other_expected 19 | ) 20 | { 21 | char *list_str = list_to_str(list); 22 | char *to_add_str = list_to_str(&to_add); 23 | set_signature_tn(test_number, "ft_lstadd_front(%s, %s)", list_str, to_add_str); 24 | free(list_str); free(to_add_str); 25 | 26 | ft_lstadd_front(list, to_add); 27 | int result1 = same_list_bool(expected, list); 28 | int result2 = same_list_bool(other_expected, list); 29 | int result = result1 || result2; 30 | if (!result) { 31 | char *res_list_str = list_to_str(list); 32 | char *expected_list_str = list_to_str(expected); 33 | char *other_expected_list_str = list_to_str(other_expected); 34 | error("different lists\n" YEL "Expected" NC ": %s\n OR: %s\n" YEL "Result " NC ": %s\n\n", 35 | expected_list_str, other_expected_list_str, res_list_str); 36 | free(res_list_str); 37 | free(expected_list_str); 38 | free(other_expected_list_str); 39 | } 40 | 41 | null_null_check(ft_lstadd_front(list, to_add), result); 42 | return result; 43 | } 44 | 45 | int test_lstadd_front() 46 | { 47 | int res = test_single_lstadd_front(1, 48 | create_list(0), lstnew("new head"), create_list(1, "new head")); 49 | res = test_single_lstadd_front(2, 50 | create_list(1, "old head"), 51 | lstnew("new head"), 52 | create_list(2, "new head", "old head")) && res; 53 | res = test_single_lstadd_front_multiple_ok(3, 54 | create_list(2, "old head", "tail"), 55 | *create_list(2, "new head", "lost node"), 56 | create_list(3, "new head", "old head", "tail"), 57 | create_list(4, "new head", "lost node", "old head", "tail") 58 | ) && res; 59 | return res; 60 | } 61 | 62 | int main() 63 | { 64 | handle_signals_with_time(); 65 | test(lstadd_front); 66 | } 67 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex02/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 19:01:09 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 07:22:25 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | char *ft_strcat(char *dest, char *src); 19 | 20 | void set_str(char *src, char *dest) 21 | { 22 | int pos = 0; 23 | 24 | while (src[pos] != '\0') 25 | { 26 | dest[pos] = src[pos]; 27 | pos++; 28 | } 29 | dest[pos] = '\0'; 30 | } 31 | 32 | bool same_str(char *expected, char *output, int len) 33 | { 34 | int pos; 35 | int res; 36 | 37 | res = 1; 38 | pos = 0; 39 | while (pos < len) 40 | { 41 | char e = expected[pos]; 42 | char o = output[pos]; 43 | if (e != o) 44 | { 45 | printf("in pos %d, expected: %d and got: %d\n", 46 | pos, e, o); 47 | res = 0; 48 | } 49 | pos++; 50 | } 51 | if (!res) 52 | printf("'%s' : '%s' \n", expected, output); 53 | return res; 54 | } 55 | 56 | void reset_strs(char *a, char *b, char *value) 57 | { 58 | set_str(value, a); 59 | set_str(value, b); 60 | } 61 | 62 | int main() { 63 | char *s2 = "aaaaa"; 64 | char s1[100] = ""; 65 | char std_s1[100] = ""; 66 | 67 | s2 = "xyz"; 68 | reset_strs(std_s1, s1, "aaaa"); 69 | char *res = ft_strcat(s1, s2); 70 | char *std_res = strcat(std_s1, s2); 71 | printf("same string: yours: '%s', std: '%s', %i\n", res, std_res, same_str(std_s1, s1, 10)); 72 | 73 | s2 = ""; 74 | reset_strs(std_s1, s1, "aaaa"); 75 | res = ft_strcat(s1, s2); 76 | std_res = strcat(std_s1, s2); 77 | printf("same string: yours: '%s', std: '%s': %i\n", res, std_res, same_str(std_res, res, 10)); 78 | } -------------------------------------------------------------------------------- /bin/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$HOME" || exit 4 | 5 | mkdir temp_____ 6 | 7 | cd temp_____ || exit 8 | rm -rf francinette 9 | 10 | # download github 11 | git clone --recursive https://github.com/xicodomingues/francinette.git 12 | 13 | if [ "$(uname)" != "Darwin" ]; then 14 | echo "Admin permissions needed to install C compilers, python, and upgrade current packages" 15 | case $(lsb_release -is) in 16 | "Ubuntu") 17 | sudo apt update 18 | sudo apt upgrade 19 | sudo apt install gcc clang libpq-dev libbsd-dev libncurses-dev valgrind -y 20 | sudo apt install python-dev python3-pip -y 21 | sudo apt install python3-dev python3-venv python3-wheel -y 22 | pip3 install wheel 23 | ;; 24 | "Arch") 25 | sudo pacman -Syu 26 | sudo pacman -S gcc clang postgresql libbsd ncurses valgrind --noconfirm 27 | sudo pacman -S python-pip --noconfirm 28 | pip3 install wheel 29 | ;; 30 | esac 31 | fi 32 | 33 | cp -r francinette "$HOME" 34 | 35 | cd "$HOME" || exit 36 | rm -rf temp_____ 37 | 38 | cd "$HOME"/francinette || exit 39 | 40 | # start a venv inside francinette 41 | if ! python3 -m venv venv ; then 42 | echo "Please make sure than you can create a python virtual environment" 43 | echo 'Contact me if you have no idea how to proceed (fsoares- on slack)' 44 | exit 1 45 | fi 46 | 47 | # activate venv 48 | . venv/bin/activate 49 | 50 | # install requirements 51 | if ! pip3 install -r requirements.txt ; then 52 | echo 'Problem launching the installer. Contact me (fsoares- on slack)' 53 | exit 1 54 | fi 55 | 56 | RC_FILE="$HOME/.zshrc" 57 | 58 | if [ "$(uname)" != "Darwin" ]; then 59 | RC_FILE="$HOME/.bashrc" 60 | if [[ -f "$HOME/.zshrc" ]]; then 61 | RC_FILE="$HOME/.zshrc" 62 | fi 63 | fi 64 | 65 | echo "try to add alias in file: $RC_FILE" 66 | 67 | # set up the alias 68 | if ! grep "francinette=" "$RC_FILE" &> /dev/null; then 69 | echo "francinette alias not present" 70 | printf "\nalias francinette=%s/francinette/tester.sh\n" "$HOME" >> "$RC_FILE" 71 | fi 72 | 73 | if ! grep "paco=" "$RC_FILE" &> /dev/null; then 74 | echo "Short alias not present. Adding it" 75 | printf "\nalias paco=%s/francinette/tester.sh\n" "$HOME" >> "$RC_FILE" 76 | fi 77 | 78 | # print help 79 | "$HOME"/francinette/tester.sh --help 80 | 81 | # automatically replace current shell with new one. 82 | exec "$SHELL" 83 | 84 | printf "\033[33m... and don't forget, \033[1;37mpaco\033[0;33m is not a replacement for your own tests! \033[0m\n" -------------------------------------------------------------------------------- /tests/cpiscine/c04/ex05/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/20 20:06:11 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 07:19:06 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | int ft_atoi_base(char *nbr, char *base); 17 | 18 | int main(void) 19 | { 20 | int res; 21 | int expected; 22 | 23 | printf("42:%d\n", ft_atoi_base("2a", "0123456789abcdef")); 24 | printf("-42:%d\n", ft_atoi_base(" --------+-2a", "0123456789abcdef")); 25 | printf("42:%d\n", ft_atoi_base(" -+-2a", "0123456789abcdef")); 26 | printf("0:%d\n", ft_atoi_base(" --------+- 2a", "0123456789abcdef")); 27 | printf("0:%d\n", ft_atoi_base(" --------+-g", "0123456789abcdef")); 28 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "")); 29 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "0")); 30 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "+-0")); 31 | printf("0:%d\n", ft_atoi_base(" --------+-2a", "\t01")); 32 | res = ft_atoi_base(" \v7fffffff", "0123456789abcdef"); 33 | printf("%d : %d (equals: %i)\n", INT_MAX, res, INT_MAX == res); 34 | res = ft_atoi_base(" \f-80000000", "0123456789abcdef"); 35 | printf("%d : %d (equals: %i)\n", INT_MIN, res, INT_MIN == res); 36 | res = ft_atoi_base("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZXEFnoY$", 37 | "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba9876543210"); 38 | printf("%d : %d (equals: %i)\n", INT_MAX, res, INT_MAX == res); 39 | 40 | res = ft_atoi_base("-~~~~~~~~'~~~~~~'~'~~~'''''''~~'$", "'~"); 41 | expected = -2143247366; 42 | printf("%d : %d (equals: %i)\n", expected, res, expected == res); 43 | } -------------------------------------------------------------------------------- /testers/get_next_line/Fsoares.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import re 4 | from typing import Set 5 | 6 | from testers.BaseExecutor import BaseExecutor 7 | from utils.ExecutionContext import has_bonus, is_strict 8 | from utils.TerminalColors import TC 9 | from utils.Utils import show_errors_file 10 | 11 | logger = logging.getLogger("gnl-fsoares") 12 | 13 | buffer_size_regex = re.compile(r"BUFFER_SIZE: (\d+)") 14 | 15 | 16 | class Fsoares(BaseExecutor): 17 | 18 | name = 'fsoares' 19 | folder = 'fsoares' 20 | git_url = 'my own tests' 21 | line_regex = re.compile(r"^([^:]+):(.+)$") 22 | test_regex = re.compile(r"(\d+)(?:[^ ]+)?\.([^ ]+)") 23 | 24 | def __init__(self, tests_dir, temp_dir, to_execute, missing) -> None: 25 | super().__init__(tests_dir, temp_dir, to_execute, missing) 26 | # macOS: suppress inconsequential but intrusive 27 | # debug messages printed by Apple's libmalloc 28 | os.environ['MallocNanoZone'] = '0' 29 | 30 | def execute(self): 31 | bonus_tests = ["open, close, open", "2 file descriptors", "multiple fds", "test limit fds"] 32 | 33 | def validate_one_static(): 34 | static_regex = re.compile(r".*\bstatic\b.*;.*") 35 | static_count = 0 36 | 37 | def count_in_file(file): 38 | nonlocal static_count 39 | with open((self.temp_dir / ".." / file).resolve()) as gnl: 40 | for line in gnl.readlines(): 41 | if static_regex.match(line): 42 | static_count += 1 43 | 44 | count_in_file("get_next_line_bonus.c") 45 | count_in_file("get_next_line_utils_bonus.c") 46 | if (static_count > 1): 47 | print(f"{TC.RED}You have more than one {TC.B_BLUE}static{TC.RED} variable {TC.NC}") 48 | return False 49 | return True 50 | 51 | def show_errors(errors: Set): 52 | if errors: 53 | show_errors_file(self.temp_dir, "error_color.log", "errors.log") 54 | 55 | self.show_test_files(errors, bonus_tests, "tester.c", "bonus.c") 56 | if has_bonus() and self.exec_bonus: 57 | if not validate_one_static(): 58 | errors.add("more than one static") 59 | if not is_strict() and not errors: 60 | print(f"Want some more thorough tests? run '{TC.B_WHITE}francinette --strict{TC.NC}'.") 61 | return errors 62 | 63 | errors = self.execute_make_command("mandatory", self.exec_mandatory) 64 | logger.info(f"errors: {errors}") 65 | bonus_errors = set(errors).union(self.execute_make_command("bonus", self.exec_bonus, True)) 66 | bonus_errors = show_errors(bonus_errors) 67 | return [self.name] if bonus_errors else [] 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | .idea/ 132 | 133 | /temp/ 134 | /c??/ 135 | .DS_Store 136 | /logs/ 137 | utils/update.toml 138 | -------------------------------------------------------------------------------- /tests/libft/fsoares/test_strnstr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | int single_test_strnstr(int test_number, char *str1, char *str2, size_t n) 5 | { 6 | set_signature_tn(test_number, "ft_strnstr(%p: %s, %s, %lu)", str1, escape_str(str1), escape_str(str2), n); 7 | char * res = ft_strnstr(str1, str2, n); 8 | char * res_std = strnstr(str1, str2, n); 9 | 10 | return same_offset(str1, res_std, str1, res); 11 | } 12 | 13 | int test_strnstr(void) 14 | { 15 | int res = 1; 16 | 17 | char empty[10]; 18 | 19 | empty[0] = 0; 20 | empty[1] = 'a'; 21 | 22 | res = single_test_strnstr(1, "abc", "xyz", 0) && res; 23 | res = single_test_strnstr(2, "abc", "xyz", 1) && res; 24 | res = single_test_strnstr(3, "", "", 0) && res; 25 | res = single_test_strnstr(4, "", "", 1) && res; 26 | res = single_test_strnstr(5, "", "", 2) && res; 27 | res = single_test_strnstr(6, "", "teste", 0) && res; 28 | res = single_test_strnstr(7, "", "teste", 1) && res; 29 | res = single_test_strnstr(8, "", "teste", 2) && res; 30 | res = single_test_strnstr(9, "teste", "", 0) && res; 31 | res = single_test_strnstr(10, "teste", "", 1) && res; 32 | res = single_test_strnstr(11, "teste", "", 2) && res; 33 | res = single_test_strnstr(12, "abcdefgh", "abc", 2) && res; 34 | res = single_test_strnstr(13, "abcdefgh", "abc", 3) && res; 35 | res = single_test_strnstr(14, "abcdefgh", "abc", 4) && res; 36 | res = single_test_strnstr(15, "abcdefgh", "abc", 5) && res; 37 | res = single_test_strnstr(16, "abc", "abcdef", 2) && res; 38 | res = single_test_strnstr(17, "abc", "abcdef", 3) && res; 39 | res = single_test_strnstr(18, "abc", "abcdef", 4) && res; 40 | res = single_test_strnstr(19, "abc", "abcdef", 5) && res; 41 | res = single_test_strnstr(20, "aaxx", "xx", 2) && res; 42 | res = single_test_strnstr(21, "aaxx", "xx", 3) && res; 43 | res = single_test_strnstr(22, "aaxx", "xx", 4) && res; 44 | res = single_test_strnstr(23, "aaxx", "xx", 5) && res; 45 | res = single_test_strnstr(24, "aaxx", "xx", 6) && res; 46 | 47 | res = single_test_strnstr(25, empty, "xx", 0xffffffff) && res; 48 | 49 | unsigned char s1[10] = "abcdef"; 50 | unsigned char s2[10] = "abc\xfdxx"; 51 | res = single_test_strnstr(26, (char *)s1, (char *)s2, 3) && res; 52 | res = single_test_strnstr(27, (char *)s1, (char *)s2, 4) && res; 53 | res = single_test_strnstr(28, (char *)s1, (char *)s2, 5) && res; 54 | 55 | s1[3] = 0; 56 | s2[3] = 0; 57 | int other = single_test_strnstr(29, (char *)s1, (char *)s2, 7); 58 | if (!other) { 59 | fprintf(errors_file, BRED "You are not stoping at the '\\0'\n" NC); 60 | res = 0; 61 | } 62 | return res; 63 | } 64 | 65 | int main() 66 | { 67 | handle_signals_with_time(); 68 | test(strnstr); 69 | } 70 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex00/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 18:37:02 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/20 19:35:02 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | char *ft_strcpy(char *dest, char *src); 17 | 18 | void set_str(char *src, char *dest) 19 | { 20 | int pos = 0; 21 | 22 | while (src[pos] != '\0') 23 | { 24 | dest[pos] = src[pos]; 25 | pos++; 26 | } 27 | dest[pos] = '\0'; 28 | } 29 | 30 | void reset_strs(char *a, char *b, char *c, char *d) 31 | { 32 | set_str("aaaaaaaaaaaaaaaaaaa", a); 33 | set_str("aaaaaaaaaaaaaaaaaaa", b); 34 | set_str("bbbbbbbbbbbbbbbbbbb", c); 35 | set_str("bbbbbbbbbbbbbbbbbbb", d); 36 | } 37 | 38 | int same_result(char *expected, char *output, int len) 39 | { 40 | int pos; 41 | int res; 42 | 43 | res = 1; 44 | pos = 0; 45 | while (pos < len) 46 | { 47 | char e = expected[pos]; 48 | char o = output[pos]; 49 | if (e != o) 50 | { 51 | res = 0; 52 | } 53 | pos++; 54 | } 55 | if (!res) 56 | printf("'%s' : '%s' \n", expected, output); 57 | return res; 58 | } 59 | 60 | int main(void) 61 | { 62 | char src[20]; 63 | char dest[20]; 64 | char std_src[20]; 65 | char std_dest[20]; 66 | 67 | reset_strs(src, std_src, dest, std_dest); 68 | set_str("", src); 69 | set_str("", std_src); 70 | set_str("efgh", dest); 71 | set_str("efgh", std_dest); 72 | printf("%d\n", same_result( 73 | strcpy(std_dest, std_src), 74 | ft_strcpy(dest, src), 75 | 3)); 76 | 77 | reset_strs(src, std_src, dest, std_dest); 78 | set_str("", dest); 79 | set_str("", std_dest); 80 | printf("%i\n", same_result(strcpy(std_dest, "abc"), ft_strcpy(dest, "abc"), 2)); 81 | 82 | 83 | reset_strs(src, std_src, dest, std_dest); 84 | set_str("ab", src); 85 | set_str("ab", std_src); 86 | set_str("efghijklm", dest); 87 | set_str("efghijklm", std_dest); 88 | printf("%d\n", same_result( 89 | strcpy(std_dest, std_src), 90 | ft_strcpy(dest, src), 3)); 91 | } -------------------------------------------------------------------------------- /tests/libft/fsoares/test_split.c: -------------------------------------------------------------------------------- 1 | 2 | #include "my_utils.h" 3 | 4 | char **init_str_array(int n, ...) 5 | { 6 | va_list argp; 7 | char **result = calloc(n, sizeof(char *)); 8 | 9 | va_start(argp, n); 10 | for (int i = 0; i < n; i++) 11 | result[i] = va_arg(argp, char *); 12 | 13 | va_end(argp); 14 | return result; 15 | } 16 | 17 | void print_string_arr(char **array) 18 | { 19 | int i = 0; 20 | char *res = array[i]; 21 | fprintf(errors_file, "["); 22 | while (res != NULL) 23 | { 24 | fprintf(errors_file, "%s, ", escape_str(res)); 25 | res = array[++i]; 26 | } 27 | fprintf(errors_file, " NULL]"); 28 | } 29 | 30 | int same_strings(char **expected, char **result) 31 | { 32 | int i = 0; 33 | bool same = true; 34 | while (expected[i] != NULL) 35 | { 36 | if (strcmp(expected[i], result[i]) != 0) 37 | same = false; 38 | i++; 39 | } 40 | same = expected[i] == result[i] && same; 41 | 42 | if (!same) 43 | { 44 | fprintf(errors_file, "\n"); 45 | error("\n" YEL "Expected: " NC); 46 | print_string_arr(expected); 47 | fprintf(errors_file, "\n" YEL "Returned: " NC); 48 | print_string_arr(result); 49 | fprintf(errors_file, "\n"); 50 | } 51 | same = check_mem_size(result, sizeof(char *) * (i + 1)) && same; 52 | return same; 53 | } 54 | 55 | int test_single_split(int test_number, char *s, char c, char **expected) 56 | { 57 | set_signature_tn(test_number, "ft_split(%s, %i:%s)", escape_str(s), c, escape_chr(c)); 58 | 59 | char **res = ft_split(s, c); 60 | 61 | int result = 1; 62 | result = same_strings(expected, res); 63 | int i = 0; 64 | while (expected[i] != NULL) 65 | { 66 | result = check_mem_size(res[i], strlen(expected[i]) + 1) && result; 67 | free(res[i]); 68 | i++; 69 | } 70 | result = check_leaks(res) && result; 71 | 72 | null_check(ft_split(s, c), result) 73 | return result; 74 | } 75 | 76 | int test_split() 77 | { 78 | char **expected = init_str_array(2, "hello!", NULL); 79 | int res = test_single_split(1, "hello!", ' ', expected); 80 | 81 | res = test_single_split(2, "xxxxxxxxhello!", 'x', expected) && res; 82 | res = test_single_split(3, "hello!zzzzzzzz", 'z', expected) && res; 83 | res = test_single_split(4, "\11\11\11\11hello!\11\11\11\11", '\11', expected) && res; 84 | 85 | expected = init_str_array(1, NULL); 86 | res = test_single_split(5, "", 'a', expected) && res; 87 | res = test_single_split(6, "ggggggggggg", 'g', expected) && res; 88 | 89 | expected = init_str_array(5, "1", "2a,", "3", "--h", NULL); 90 | res = test_single_split(7, "^^^1^^2a,^^^^3^^^^--h^^^^", '^', expected) && res; 91 | 92 | expected = init_str_array(2, "nonempty", NULL); 93 | res = test_single_split(8, "nonempty", '\0', expected) && res; 94 | 95 | return res; 96 | } 97 | 98 | int main() 99 | { 100 | handle_signals_with_time(); 101 | test(split); 102 | } 103 | -------------------------------------------------------------------------------- /utils/update.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import ssl 4 | from datetime import datetime, timedelta 5 | from pathlib import Path 6 | import subprocess 7 | from urllib.request import urlopen 8 | 9 | import certifi 10 | import toml 11 | from git import Repo 12 | from packaging import version as vs 13 | from rich import print 14 | 15 | from utils.ExecutionContext import console 16 | from utils.Utils import REPO_URL 17 | from utils.version import version as current 18 | 19 | DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S' 20 | toml_path = Path(__file__, "../update.toml").resolve() 21 | 22 | logger = logging.getLogger("update") 23 | 24 | 25 | def save_settings(settings): 26 | with open(toml_path, 'w') as f: 27 | toml.dump(settings, f) 28 | 29 | 30 | def ignore_this_new_version(settings, new_version): 31 | settings['paco']['ignored'] = new_version 32 | save_settings(settings) 33 | 34 | 35 | def do_not_update_ever(settings): 36 | settings['paco']['do_not_update'] = True 37 | save_settings(settings) 38 | 39 | 40 | def get_settings(): 41 | try: 42 | return toml.load(toml_path) 43 | except: 44 | return {'paco': {'last_run': None}} 45 | 46 | 47 | def update_paco(): 48 | settings = get_settings() 49 | if settings['paco'].get('do_not_update', False): 50 | return 51 | 52 | last_run = settings['paco']['last_run'] 53 | if last_run and datetime.strptime(last_run, DATETIME_FORMAT) > datetime.now() - timedelta(hours=1): 54 | return save_settings(settings) 55 | settings['paco']['last_run'] = datetime.strftime(datetime.now(), DATETIME_FORMAT) 56 | 57 | try: 58 | with urlopen(REPO_URL + "utils/version.py", context=ssl.create_default_context(cafile=certifi.where()), timeout=5) as data: 59 | new_version = data.read().decode("utf-8").split('"')[1] 60 | except: 61 | print("Problem checking the last version. Please make sure you have an internet connection") 62 | return 63 | 64 | if (vs.parse(current) >= vs.parse(new_version) or 65 | vs.parse(settings['paco'].get('ignored', '0.0.0')) >= vs.parse(new_version)): 66 | return save_settings(settings) 67 | 68 | if settings['paco'].get('always', False): 69 | do_update() 70 | return 71 | 72 | print(f"There is a new version of francinette ({current} -> {new_version}), do you wish to update?") 73 | while (True): 74 | choice = input("[Y]es / [N]o / [A]lways / [D]o not update ever: ").lower() 75 | if choice.startswith('y'): 76 | break 77 | if choice.startswith('n'): 78 | return ignore_this_new_version(settings, new_version) 79 | if choice.startswith('d'): 80 | return do_not_update_ever(settings) 81 | if choice.startswith('a'): 82 | settings['paco']['always'] = True 83 | break 84 | else: 85 | print("Please select one of the available options") 86 | save_settings(settings) 87 | do_update() 88 | 89 | 90 | def do_update(): 91 | path = Path(__file__, "../../bin/update.sh").resolve() 92 | subprocess.run(str(path), shell=True) 93 | -------------------------------------------------------------------------------- /testers/cpiscine/C02Tester.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import Match 3 | 4 | from testers.cpiscine.CommonTester import CommonTester, VeriOut 5 | from utils.ExecutionContext import TestRunInfo 6 | 7 | 8 | class C02Tester(CommonTester): 9 | 10 | name = "c02" 11 | 12 | def __init__(self, info: TestRunInfo): 13 | super().__init__(info) 14 | 15 | def ex00(self): 16 | self.exercise_files = ["ft_strcpy.c"] 17 | self.test_files = ["main.c"] 18 | 19 | def ex01(self): 20 | self.exercise_files = ["ft_strncpy.c"] 21 | self.test_files = ["main.c"] 22 | 23 | def ex02(self): 24 | self.exercise_files = ["ft_str_is_alpha.c"] 25 | self.test_files = ["main.c"] 26 | 27 | def ex03(self): 28 | self.exercise_files = ["ft_str_is_numeric.c"] 29 | self.test_files = ["main.c"] 30 | 31 | def ex04(self): 32 | self.exercise_files = ["ft_str_is_lowercase.c"] 33 | self.test_files = ["main.c"] 34 | 35 | def ex05(self): 36 | self.exercise_files = ["ft_str_is_uppercase.c"] 37 | self.test_files = ["main.c"] 38 | 39 | def ex06(self): 40 | self.exercise_files = ["ft_str_is_printable.c"] 41 | self.test_files = ["main.c"] 42 | 43 | def ex07(self): 44 | self.exercise_files = ["ft_strupcase.c"] 45 | self.test_files = ["main.c"] 46 | 47 | def ex08(self): 48 | self.exercise_files = ["ft_strlowcase.c"] 49 | self.test_files = ["main.c"] 50 | 51 | def ex09(self): 52 | self.exercise_files = ["ft_strcapitalize.c"] 53 | self.test_files = ["main.c"] 54 | 55 | def ex10(self): 56 | self.exercise_files = ["ft_strlcpy.c"] 57 | self.test_files = ["main.c"] 58 | 59 | def ex11(self): 60 | self.exercise_files = ["ft_putstr_non_printable.c"] 61 | self.test_files = ["main.c"] 62 | 63 | def ex12(self): 64 | self.exercise_files = ["ft_print_memory.c"] 65 | self.test_files = ["main.c"] 66 | 67 | @staticmethod 68 | def ex12_verification(): 69 | 70 | def get_replacement(first_value): 71 | 72 | def replace(match: Match): 73 | return f"{(int(match.group(1), 16) - first_value):0>16x}" 74 | 75 | return replace 76 | 77 | def truncate(lines): 78 | return lines[:2] + ["..."] + lines[-2:] 79 | 80 | with open("out") as outfile, open("expected") as expfile: 81 | outlines = outfile.readlines() 82 | explines = expfile.readlines() 83 | 84 | if len(outlines) != len(explines): 85 | return VeriOut( 86 | -1, f"The out and expected files " 87 | f"do not have the same number of lines:" 88 | f" {truncate(outlines)}, {truncate(outlines)}") 89 | 90 | first_value_out = int(outlines[1].split(":")[0], 16) 91 | first_value_exp = int(explines[1].split(":")[0], 16) 92 | for i in range(len(outlines)): 93 | line2 = re.sub(r"^([0-9a-f]{16}):", get_replacement(first_value_exp), explines[i]) 94 | line1 = re.sub(r"^([0-9a-f]{16}):", get_replacement(first_value_out), outlines[i]) 95 | if line1 != line2: 96 | return VeriOut(-2, f"These lines should be equal:\n{repr(line1)}\n{repr(line2)}") 97 | return VeriOut(0, "Ok") 98 | -------------------------------------------------------------------------------- /tests/cpiscine/c02/ex01/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/08 20:37:38 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/15 19:35:39 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | char *ft_strncpy(char *dest, char *src, unsigned int n); 18 | 19 | void set_str(char *src, char *dest) 20 | { 21 | int pos = 0; 22 | 23 | while (src[pos] != '\0') 24 | { 25 | dest[pos] = src[pos]; 26 | pos++; 27 | } 28 | dest[pos] = '\0'; 29 | } 30 | void reset_strs(char *a, char *b, char *c, char *d) 31 | { 32 | set_str("aaaaaaaaaaaaaaaaaaa", a); 33 | set_str("aaaaaaaaaaaaaaaaaaa", b); 34 | set_str("bbbbbbbbbbbbbbbbbbb", c); 35 | set_str("bbbbbbbbbbbbbbbbbbb", d); 36 | } 37 | 38 | bool same_result(char *expected, char *output, int len) 39 | { 40 | int pos; 41 | int res; 42 | 43 | res = 1; 44 | pos = 0; 45 | while (pos < len) 46 | { 47 | char e = expected[pos]; 48 | char o = output[pos]; 49 | if (e != o) 50 | { 51 | printf("in pos %d, expected: %d and got: %d\n", 52 | pos, e, o); 53 | res = 0; 54 | } 55 | pos++; 56 | } 57 | if (!res) 58 | printf("'%s' : '%s' \n", expected, output); 59 | return res; 60 | } 61 | 62 | int main(void) 63 | { 64 | char src[20]; 65 | char dest[20]; 66 | char std_src[20]; 67 | char std_dest[20]; 68 | 69 | reset_strs(src, std_src, dest, std_dest); 70 | set_str("abcd", src); 71 | set_str("abcd", std_src); 72 | set_str("efgh", dest); 73 | set_str("efgh", std_dest); 74 | printf("%d\n", same_result( 75 | strncpy(std_dest, std_src, 0), 76 | ft_strncpy(dest, src, 0), 77 | 3)); 78 | 79 | reset_strs(src, std_src, dest, std_dest); 80 | set_str("abcd", src); 81 | set_str("abcd", std_src); 82 | set_str("efgh", dest); 83 | set_str("efgh", std_dest); 84 | printf("%d\n", same_result( 85 | strncpy(std_dest, std_src, 2), 86 | ft_strncpy(dest, src, 2), 87 | 5)); 88 | 89 | reset_strs(src, std_src, dest, std_dest); 90 | set_str("ab", src); 91 | set_str("ab", std_src); 92 | set_str("efghijklm", dest); 93 | set_str("efghijklm", std_dest); 94 | printf("%d\n", same_result( 95 | strncpy(std_dest, std_src, 8), 96 | ft_strncpy(dest, src, 8), 97 | 8)); 98 | } 99 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex04/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 19:01:09 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 07:22:29 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | char *ft_strstr(char *str, char *to_find); 19 | 20 | void set_str(char *src, char *dest) 21 | { 22 | int pos = 0; 23 | 24 | while (src[pos] != '\0') 25 | { 26 | dest[pos] = src[pos]; 27 | pos++; 28 | } 29 | dest[pos] = '\0'; 30 | } 31 | 32 | bool same_str(char *expected, char *output, int len) 33 | { 34 | int pos; 35 | int res; 36 | 37 | res = 1; 38 | pos = 0; 39 | while (pos < len) 40 | { 41 | char e = expected[pos]; 42 | char o = output[pos]; 43 | if (e != o) 44 | { 45 | printf("in pos %d, expected: %d and got: %d\n", 46 | pos, e, o); 47 | res = 0; 48 | } 49 | pos++; 50 | } 51 | if (!res) 52 | printf("'%s' : '%s' \n", expected, output); 53 | return res; 54 | } 55 | 56 | void reset_strs(char *a, char *b, char *value) 57 | { 58 | set_str(value, a); 59 | set_str(value, b); 60 | } 61 | 62 | int main() { 63 | char *s1 = "xxxxxxxx"; 64 | char *s2 = ""; 65 | 66 | char *res = ft_strstr(s1, s2); 67 | char *std_res = strstr(s1, s2); 68 | printf("return the same positon: %i (yours: '%lu', std: '%lu')\n", res == std_res, res - s1, std_res - s1); 69 | 70 | s1 = "xyxyza"; 71 | s2 = "xyz"; 72 | res = ft_strstr(s1, s2); 73 | std_res = strstr(s1, s2); 74 | printf("return the same positon: %i (yours: '%lu', std: '%lu')\n", res == std_res, (res - s1), (std_res - s1)); 75 | 76 | s1 = "xyxyaza"; 77 | s2 = "xyz"; 78 | res = ft_strstr(s1, s2); 79 | std_res = strstr(s1, s2); 80 | printf("return NULL on no match: %i, %i\n", res == NULL, std_res == NULL); 81 | 82 | s1 = "xyxyza"; 83 | s2 = ""; 84 | res = ft_strstr(s1, s2); 85 | std_res = strstr(s1, s2); 86 | printf("return the first position on empty string: %i (yours: '%lu', std: '%lu')\n", res == std_res, (res - s1), (std_res - s1)); 87 | 88 | s1 = ""; 89 | s2 = ""; 90 | res = ft_strstr(s1, s2); 91 | std_res = strstr(s1, s2); 92 | printf("return same position on both empty strings: %i\n", res == std_res); 93 | 94 | s1 = ""; 95 | s2 = "xxx"; 96 | res = ft_strstr(s1, s2); 97 | std_res = strstr(s1, s2); 98 | printf("return NULL if src is empty: %i (yours: '%p', std: '%p')\n", res == std_res, res , std_res); 99 | } -------------------------------------------------------------------------------- /testers/libft/Libft.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | import re 4 | import shutil 5 | from pathlib import Path 6 | 7 | from halo import Halo 8 | from testers.BaseTester import BaseTester, run_command 9 | from testers.libft.Alelievr import Alelievr 10 | from testers.libft.BaseExecutor import (BONUS_FUNCTIONS, PART_1_FUNCTIONS, 11 | PART_2_FUNCTIONS) 12 | from testers.libft.Fsoares import Fsoares 13 | from testers.libft.Tripouille import Tripouille 14 | from testers.libft.WarMachine import WarMachine 15 | from utils.ExecutionContext import TestRunInfo, set_bonus 16 | from utils.TerminalColors import TC 17 | from utils.Utils import is_makefile_project 18 | 19 | logger = logging.getLogger("libft") 20 | 21 | func_regex = re.compile(r"(?:\w+\s+)+\**ft_(\w+)\s*\(.*") 22 | 23 | 24 | class Libft(BaseTester): 25 | 26 | name = "libft" 27 | my_tester = Fsoares 28 | testers = [WarMachine, Tripouille, Alelievr, Fsoares] 29 | timeout = 2 30 | 31 | def __init__(self, info: TestRunInfo) -> None: 32 | super().__init__(info) 33 | super().execute_testers() 34 | 35 | @staticmethod 36 | def is_project(current_path): 37 | return is_makefile_project(current_path, "libft.a", Libft) 38 | 39 | def select_tests_to_execute(self): 40 | args = self.info.args 41 | if (args.mandatory or args.bonus): 42 | all_funcs = [] 43 | if (args.mandatory): 44 | all_funcs.extend(PART_1_FUNCTIONS) 45 | all_funcs.extend(PART_2_FUNCTIONS) 46 | if (args.bonus): 47 | all_funcs.extend(BONUS_FUNCTIONS) 48 | set_bonus(True) 49 | return all_funcs 50 | 51 | all_funcs = PART_1_FUNCTIONS + PART_2_FUNCTIONS 52 | if self.has_bonus(): 53 | all_funcs = all_funcs + BONUS_FUNCTIONS 54 | set_bonus(True) 55 | return all_funcs 56 | 57 | 58 | def prepare_tests(self, tester): 59 | super().prepare_tests(tester) 60 | temp_dir = os.path.join(self.temp_dir, tester.folder) 61 | 62 | # copy compiled library 63 | library = os.path.join(self.temp_dir, "libft.a") 64 | if not os.path.exists(library): 65 | raise Exception(f"{TC.B_RED}libft.a{TC.RED} was not created. Please create it in the Makefile.") 66 | logger.info(f"Copying libft.a from {library} to {temp_dir}") 67 | shutil.copy(library, temp_dir) 68 | 69 | # copy header 70 | header = os.path.join(self.temp_dir, "libft.h") 71 | logger.info(f"Copying libft.h from {header} to {temp_dir}") 72 | shutil.copy(header, temp_dir) 73 | 74 | return True 75 | 76 | def get_functions_present(self): 77 | header = os.path.join(self.temp_dir, "libft.h") 78 | if not os.path.exists(header): 79 | raise Exception(f"There is no {TC.B_RED}libft.h{TC.RED} present") 80 | with open(header, "r") as h: 81 | funcs_str = [line for line in h.readlines() if func_regex.match(line)] 82 | return [func_regex.match(line).group(1) for line in funcs_str] 83 | 84 | def compile_source(self): 85 | os.chdir(os.path.join(self.temp_dir)) 86 | makefile = Path(self.temp_dir, "Makefile") 87 | if not makefile.exists(): 88 | return 89 | command = "make fclean all" + (" bonus" if self.has_bonus() else "") 90 | logger.info(f"Calling '{command}' on directory {os.getcwd()}") 91 | 92 | text = f"{TC.CYAN}Executing: {TC.B_WHITE}{command}{TC.NC} " + ("" if self.has_bonus() else "(no bonus)") 93 | with Halo(text=text) as spinner: 94 | run_command(command, spinner) 95 | spinner.succeed() 96 | -------------------------------------------------------------------------------- /tests/cpiscine/c03/ex03/main.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* main.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: fsoares- +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2021/12/16 19:01:09 by fsoares- #+# #+# */ 9 | /* Updated: 2021/12/21 07:22:27 by fsoares- ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | char *ft_strncat(char *dest, char *src, unsigned int n); 19 | 20 | void set_str(char *src, char *dest) 21 | { 22 | int pos = 0; 23 | 24 | while (src[pos] != '\0') 25 | { 26 | dest[pos] = src[pos]; 27 | pos++; 28 | } 29 | dest[pos] = '\0'; 30 | } 31 | 32 | bool same_str(char *expected, char *output, int len) 33 | { 34 | int pos; 35 | int res; 36 | 37 | res = 1; 38 | pos = 0; 39 | while (pos < len) 40 | { 41 | char e = expected[pos]; 42 | char o = output[pos]; 43 | if (e != o) 44 | { 45 | printf("in pos %d, expected: %d and got: %d\n", 46 | pos, e, o); 47 | res = 0; 48 | } 49 | pos++; 50 | } 51 | if (!res) 52 | printf("'%s' : '%s' \n", expected, output); 53 | return res; 54 | } 55 | 56 | void reset_strs(char *a, char *b, char *value) 57 | { 58 | set_str(value, a); 59 | set_str(value, b); 60 | } 61 | 62 | int main() { 63 | char *s2 = "aaaaa"; 64 | char s1[100] = ""; 65 | char std_s1[100] = ""; 66 | int n = 0; 67 | 68 | s2 = "xyz"; 69 | reset_strs(std_s1, s1, "aaaa"); 70 | char *res = ft_strncat(s1, s2, n); 71 | char *std_res = strncat(std_s1, s2, n); 72 | printf("n: %i, same string: yours: '%s', std: '%s', %i\n", n, res, std_res, same_str(std_s1, s1, 10)); 73 | 74 | n = 2; 75 | s2 = "xyz"; 76 | reset_strs(std_s1, s1, "aaaa"); 77 | res = ft_strncat(s1, s2, n); 78 | std_res = strncat(std_s1, s2, n); 79 | printf("n: %i, same string: yours: '%s', std: '%s', %i\n", n, res, std_res, same_str(std_s1, s1, 10)); 80 | 81 | n = 3; 82 | s2 = "xyz"; 83 | reset_strs(std_s1, s1, "aaaa"); 84 | res = ft_strncat(s1, s2, n); 85 | std_res = strncat(std_s1, s2, n); 86 | printf("n: %i, same string: yours: '%s', std: '%s', %i\n", n, res, std_res, same_str(std_s1, s1, 10)); 87 | 88 | n = 4; 89 | s2 = "xyz"; 90 | reset_strs(std_s1, s1, "aaaa"); 91 | res = ft_strncat(s1, s2, n); 92 | std_res = strncat(std_s1, s2, n); 93 | printf("n: %i, same string: yours: '%s', std: '%s', %i\n", n, res, std_res, same_str(std_s1, s1, 10)); 94 | 95 | n = 5; 96 | s2 = "xyz"; 97 | reset_strs(std_s1, s1, "aaaa"); 98 | res = ft_strncat(s1, s2, n); 99 | std_res = strncat(std_s1, s2, n); 100 | printf("n: %i, same string: yours: '%s', std: '%s', %i\n", n, res, std_res, same_str(std_s1, s1, 10)); 101 | } -------------------------------------------------------------------------------- /testers/libft/Alelievr.py: -------------------------------------------------------------------------------- 1 | 2 | import logging 3 | import os 4 | from pathlib import Path 5 | import re 6 | import subprocess 7 | from sys import platform 8 | from halo import Halo 9 | from typing import List 10 | from testers.libft.BaseExecutor import BONUS_FUNCTIONS 11 | from utils.ExecutionContext import get_timeout, has_bonus 12 | 13 | from utils.TerminalColors import TC 14 | from utils.Utils import decode_ascii, open_ascii 15 | 16 | logger = logging.getLogger("alelievr") 17 | 18 | func_regex = re.compile(r'^\s+\{"ft_(\w+)",.*') 19 | out_func_line = re.compile(r'^ft_(\w+):.*') 20 | 21 | class Alelievr(): 22 | 23 | name = "libft-unit-test" 24 | folder = "alelievr" 25 | git_url = "https://github.com/alelievr/libft-unit-test" 26 | 27 | def __init__(self, tests_dir, temp_dir, to_execute: List[str], missing) -> None: 28 | self.temp_dir = os.path.join(temp_dir, self.folder) 29 | self.to_execute = to_execute 30 | self.missing = list(missing) 31 | self.tests_dir = os.path.join(tests_dir, self.folder) 32 | 33 | if not has_bonus(): 34 | self.missing += BONUS_FUNCTIONS 35 | 36 | def execute(self): 37 | self.prepare_tests() 38 | return self.execute_tester() 39 | 40 | def prepare_tests(self): 41 | def handle_line(line: str): 42 | match = func_regex.match(line) 43 | if (match and match.group(1) in self.missing): 44 | return "//" + line 45 | return line 46 | 47 | init = Path(self.temp_dir, 'src', 'init.c') 48 | with open(init, 'r') as f_init: 49 | lines = [handle_line(line) for line in f_init.readlines()] 50 | with open(init, 'w') as f_init: 51 | f_init.writelines(lines) 52 | 53 | if platform == "linux" or platform == "linux2": 54 | with open(Path(self.temp_dir, "..", "__my_srcs", "Makefile"), 'a') as mf: 55 | mf.writelines("\n\nso:\n\tgcc -nostartfiles -shared -o libft.so *.o\n") 56 | 57 | def execute_tester(self): 58 | os.chdir(self.temp_dir) 59 | logger.info(f"On directory {os.getcwd()} Executing alelievr") 60 | 61 | text = f"{TC.CYAN}Compiling tests: {TC.B_WHITE}{self.name}{TC.NC} ({self.git_url})" 62 | with Halo(text) as spinner: 63 | p = subprocess.run(["make", f"TIMEOUT={get_timeout() * 1_000}" , "all"], capture_output=True) 64 | logger.info(p) 65 | if p.returncode != 0: 66 | error = p.stderr.decode('ascii', errors="backslashreplace") 67 | spinner.fail() 68 | print(error) 69 | raise Exception("Problem compiling tests") 70 | spinner.succeed() 71 | Halo(text=f"{TC.CYAN}Testing:{TC.NC}").info() 72 | p = subprocess.Popen("./run_test", stdout=subprocess.PIPE) 73 | for line in p.stdout: 74 | line_str = decode_ascii(line).rstrip() 75 | print(line_str) 76 | 77 | logger.info(p) 78 | return self.parse_output() 79 | 80 | def parse_output(self): 81 | def is_error(line): 82 | if out_func_line.match(line): 83 | for test in re.finditer(r"\[([^\]]+)\]", line): 84 | if test.group(1) != 'OK': 85 | return True 86 | return False 87 | 88 | def show_file_output(path): 89 | with open_ascii(path) as file: 90 | error_lines = [line for line in file.readlines() if not out_func_line.match(line)] 91 | print(" ".join(error_lines[:50]), end="") 92 | if (len(error_lines) > 50): 93 | print(f"...\n\nFile too large. To see full report open: {TC.PURPLE}{log_path}{TC.NC}\n") 94 | 95 | log_path = Path(self.temp_dir, 'result.log') 96 | with open_ascii(log_path) as file: 97 | errors = [out_func_line.match(line).group(1) for line in file.readlines() if is_error(line)] 98 | if len(errors) > 0: 99 | show_file_output(log_path) 100 | return errors -------------------------------------------------------------------------------- /bin/clean_cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Author Omar BOUYKOURNE 3 | #42login : obouykou 4 | 5 | echo -e "from: https://github.com/ombhd/Cleaner_42\n" 6 | 7 | #banner 8 | echo -e "\n" 9 | echo -e " █▀▀ █▀▀ █░░ █▀▀ ▄▀█ █▄░█ " 10 | echo -e " █▄▄ █▄▄ █▄▄ ██▄ █▀█ █░▀█ " 11 | echo -en "\n By: " 12 | echo -e "\033[33mOMBHD\033[0m [𝒐𝒃𝒐𝒖𝒚𝒌𝒐𝒖]\n" 13 | 14 | #calculating the current available storage 15 | Storage=$(df -h "$HOME" | grep "$HOME" | awk '{print($4)}' | tr 'i' 'B') 16 | if [ "$Storage" == "0BB" ]; 17 | then 18 | Storage="0B" 19 | fi 20 | echo -e "\033[33m\n -- Available Storage Before Cleaning : || $Storage || --\033[0m" 21 | 22 | echo -e "\033[31m\n -- Cleaning ...\n\033[0m " 23 | 24 | #42 Caches 25 | /bin/rm -rf "$HOME"/Library/*.42* &>/dev/null 26 | /bin/rm -rf "$HOME"/*.42* &>/dev/null 27 | /bin/rm -rf "$HOME"/.zcompdump* &>/dev/null 28 | /bin/rm -rf "$HOME"/.cocoapods.42_cache_bak* &>/dev/null 29 | 30 | #Trash 31 | /bin/rm -rf "$HOME"/.Trash/* &>/dev/null 32 | 33 | #General Caches files 34 | #giving access rights on Homebrew caches, so the script can delete them 35 | /bin/chmod -R 777 "$HOME"/Library/Caches/Homebrew &>/dev/null 36 | /bin/rm -rf "$HOME"/Library/Caches/* &>/dev/null 37 | /bin/rm -rf "$HOME"/Library/Application\ Support/Caches/* &>/dev/null 38 | 39 | #Slack, VSCode, Discord and Chrome Caches 40 | /bin/rm -rf "$HOME"/Library/Application\ Support/Slack/Service\ Worker/CacheStorage/* &>/dev/null 41 | /bin/rm -rf "$HOME"/Library/Application\ Support/Slack/Cache/* &>/dev/null 42 | /bin/rm -rf "$HOME"/Library/Application\ Support/discord/Cache/* &>/dev/null 43 | /bin/rm -rf "$HOME"/Library/Application\ Support/discord/Code\ Cache/js* &>/dev/null 44 | /bin/rm -rf "$HOME"/Library/Application\ Support/discord/Crashpad/completed/* &>/dev/null 45 | /bin/rm -rf "$HOME"/Library/Application\ Support/Code/Cache/* &>/dev/null 46 | /bin/rm -rf "$HOME"/Library/Application\ Support/Code/CachedData/* &>/dev/null 47 | /bin/rm -rf "$HOME"/Library/Application\ Support/Code/Crashpad/completed/* &>/dev/null 48 | /bin/rm -rf "$HOME"/Library/Application\ Support/Code/User/workspaceStorage/* &>/dev/null 49 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Profile\ [0-9]/Service\ Worker/CacheStorage/* &>/dev/null 50 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Default/Service\ Worker/CacheStorage/* &>/dev/null 51 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Profile\ [0-9]/Application\ Cache/* &>/dev/null 52 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Default/Application\ Cache/* &>/dev/null 53 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Crashpad/completed/* &>/dev/null 54 | 55 | #.DS_Store files 56 | find "$HOME"/Desktop -name .DS_Store -depth -exec /bin/rm {} \; &>/dev/null 57 | 58 | #tmp downloaded files with browsers 59 | /bin/rm -rf "$HOME"/Library/Application\ Support/Chromium/Default/File\ System &>/dev/null 60 | /bin/rm -rf "$HOME"/Library/Application\ Support/Chromium/Profile\ [0-9]/File\ System &>/dev/null 61 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Default/File\ System &>/dev/null 62 | /bin/rm -rf "$HOME"/Library/Application\ Support/Google/Chrome/Profile\ [0-9]/File\ System &>/dev/null 63 | 64 | #things related to pool (piscine) 65 | /bin/rm -rf "$HOME"/Desktop/Piscine\ Rules\ *.mp4 66 | /bin/rm -rf "$HOME"/Desktop/PLAY_ME.webloc 67 | 68 | #things related to francinette 69 | /bin/rm -rf "$HOME"/francinette/temp 70 | 71 | #calculating the new available storage after cleaning 72 | Storage=$(df -h "$HOME" | grep "$HOME" | awk '{print($4)}' | tr 'i' 'B') 73 | if [ "$Storage" == "0BB" ]; 74 | then 75 | Storage="0B" 76 | fi 77 | 78 | echo -e "\033[32m -- Available Storage After Cleaning : || $Storage || --\n\033[0m" 79 | 80 | echo -e "\n report any issues to me in:" 81 | echo -e " GitHub ~> \033[4;1;34mombhd\033[0m" 82 | echo -e " 42 Slack ~> \033[4;1;34mobouykou\033[0m\n" --------------------------------------------------------------------------------