diff --git a/d01/ex04/unitests/file_does_not_exist.replace b/d01/ex04/unitests/file_does_not_exist.replace new file mode 100644 index 0000000..e69de29 diff --git a/d01/ex04/unitests/test.sh b/d01/ex04/unitests/test.sh index b014a20..6626ecc 100644 --- a/d01/ex04/unitests/test.sh +++ b/d01/ex04/unitests/test.sh @@ -14,8 +14,8 @@ fi # RUN TESTS function run_tests { - touch $TESTNAME - echo "$CONTENT" > $TESTNAME + if [ -f $TESTNAME ];then + echo "$CONTENT" > $TESTNAME;fi $LEAKS ../$EXECUTABLE $TESTNAME "$FIND" "$REPLACEMENT" OUTPUT=$( cat $TESTNAME.replace ) @@ -26,11 +26,13 @@ fi echo -e $B_RED"$TESTNAME faillure"$ENDCO fi - mv $TESTNAME $TESTNAME.replace ./test_log + if [ -f $TESTNAME ];then + mv $TESTNAME $TESTNAME.replace ./test_log;fi } # TEST 1 ######################################## -TESTNAME="test1" +TESTNAME="one_line_file" +touch $TESTNAME FIND=" " REPLACEMENT="hello" CONTENT=" " @@ -38,7 +40,8 @@ RESULT="hello" run_tests # TEST 2 ######################################## -TESTNAME="test2" +TESTNAME="multi_line_file" +touch $TESTNAME FIND="ie" REPLACEMENT="++" CONTENT=$(cat << EOF @@ -60,7 +63,8 @@ EOF run_tests # TEST 3 ######################################## -TESTNAME="test3" +TESTNAME="replace_one_character" +touch $TESTNAME FIND="." REPLACEMENT="+" CONTENT=$(cat << EOF @@ -74,7 +78,8 @@ EOF run_tests # TEST 4 ######################################## -TESTNAME="test4" +TESTNAME="replace_two_characters" +touch $TESTNAME FIND=".." REPLACEMENT="++" CONTENT=$(cat << EOF @@ -90,7 +95,8 @@ EOF run_tests # TEST 5 ######################################## -TESTNAME="test5" +TESTNAME="first_letter_lure" +touch $TESTNAME FIND="mdr" REPLACEMENT="|||" CONTENT=$(cat << EOF @@ -104,7 +110,8 @@ EOF run_tests # TEST 6 ######################################## -TESTNAME="test6" +TESTNAME="half_replacement_lure" +touch $TESTNAME FIND="toutouille" REPLACEMENT="||||||||||" CONTENT=$(cat << EOF @@ -120,7 +127,8 @@ EOF run_tests # TEST 7 ######################################## -TESTNAME="test7" +TESTNAME="special_character_'" +touch $TESTNAME FIND="n't" REPLACEMENT="000" CONTENT=$(cat << EOF @@ -186,7 +194,8 @@ EOF run_tests # TEST 8 ######################################## -TESTNAME="test8" +TESTNAME="multiline_replacement" +touch $TESTNAME FIND=$(cat << EOF ry I don't @@ -214,7 +223,8 @@ EOF run_tests # TEST 9 ######################################## -TESTNAME="test9" +TESTNAME="empty_find" +touch $TESTNAME FIND="" REPLACEMENT="p" CONTENT=$(cat << EOF @@ -234,7 +244,8 @@ EOF run_tests # TEST 10 ######################################## -TESTNAME="test10" +TESTNAME="empty_find_and_replacement" +touch $TESTNAME FIND="" REPLACEMENT="" CONTENT=$(cat << EOF @@ -253,3 +264,37 @@ EOF ) run_tests +# TEST 11 ######################################## +TESTNAME="empty_replacement" +touch $TESTNAME +FIND="a" +REPLACEMENT="" +CONTENT=$(cat << EOF +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why +EOF +) +RESULT=$(cat << EOF +No more ters, my hert is dry +I don't lugh nd I don't cry +I don't think bout you ll the time +But when I do - I wonder why +EOF +) +run_tests + +# TEST 12 ######################################## +TESTNAME="file_does_not_exist" +FIND="o" +REPLACEMENT="O" +CONTENT=$(cat << EOF +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why +EOF +) +RESULT="" +run_tests diff --git a/d01/ex04/unitests/test13.replace b/d01/ex04/unitests/test13.replace new file mode 100644 index 0000000..e69de29 diff --git a/d01/ex04/unitests/test_log/empty_find b/d01/ex04/unitests/test_log/empty_find new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_find @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/empty_find.replace b/d01/ex04/unitests/test_log/empty_find.replace new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_find.replace @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/empty_find_and_replacement b/d01/ex04/unitests/test_log/empty_find_and_replacement new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_find_and_replacement @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/empty_find_and_replacement.replace b/d01/ex04/unitests/test_log/empty_find_and_replacement.replace new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_find_and_replacement.replace @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/empty_replacement b/d01/ex04/unitests/test_log/empty_replacement new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_replacement @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/empty_replacement.replace b/d01/ex04/unitests/test_log/empty_replacement.replace new file mode 100644 index 0000000..c6854d9 --- /dev/null +++ b/d01/ex04/unitests/test_log/empty_replacement.replace @@ -0,0 +1,4 @@ +No more ters, my hert is dry +I don't lugh nd I don't cry +I don't think bout you ll the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/first_letter_lure b/d01/ex04/unitests/test_log/first_letter_lure new file mode 100644 index 0000000..671f5ed --- /dev/null +++ b/d01/ex04/unitests/test_log/first_letter_lure @@ -0,0 +1 @@ +test de mmdr foubar diff --git a/d01/ex04/unitests/test_log/first_letter_lure.replace b/d01/ex04/unitests/test_log/first_letter_lure.replace new file mode 100644 index 0000000..991bdd3 --- /dev/null +++ b/d01/ex04/unitests/test_log/first_letter_lure.replace @@ -0,0 +1 @@ +test de m||| foubar diff --git a/d01/ex04/unitests/test_log/half_replacement_lure b/d01/ex04/unitests/test_log/half_replacement_lure new file mode 100644 index 0000000..a74f1c0 --- /dev/null +++ b/d01/ex04/unitests/test_log/half_replacement_lure @@ -0,0 +1,2 @@ +trouve ce mot toutouille +et celui-la toutoutouille diff --git a/d01/ex04/unitests/test_log/half_replacement_lure.replace b/d01/ex04/unitests/test_log/half_replacement_lure.replace new file mode 100644 index 0000000..8072725 --- /dev/null +++ b/d01/ex04/unitests/test_log/half_replacement_lure.replace @@ -0,0 +1,2 @@ +trouve ce mot |||||||||| +et celui-la tou|||||||||| \ No newline at end of file diff --git a/d01/ex04/unitests/test_log/multi_line_file b/d01/ex04/unitests/test_log/multi_line_file new file mode 100644 index 0000000..23b0c96 --- /dev/null +++ b/d01/ex04/unitests/test_log/multi_line_file @@ -0,0 +1,5 @@ +ce fichier +contient +plusieurs lignes +les unes au dessus des autres +youhouuu ioieux diff --git a/d01/ex04/unitests/test_log/multi_line_file.replace b/d01/ex04/unitests/test_log/multi_line_file.replace new file mode 100644 index 0000000..a573c23 --- /dev/null +++ b/d01/ex04/unitests/test_log/multi_line_file.replace @@ -0,0 +1,5 @@ +ce fich++r +cont++nt +plus++urs lignes +les unes au dessus des autres +youhouuu io++ux diff --git a/d01/ex04/unitests/test_log/multiline_replacement b/d01/ex04/unitests/test_log/multiline_replacement new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/multiline_replacement @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/multiline_replacement.replace b/d01/ex04/unitests/test_log/multiline_replacement.replace new file mode 100644 index 0000000..3a2e850 --- /dev/null +++ b/d01/ex04/unitests/test_log/multiline_replacement.replace @@ -0,0 +1,4 @@ +No more tears, my heart is doo +oooooooolaugh and I don't coo +oooooooothink about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/one_line_file b/d01/ex04/unitests/test_log/one_line_file new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/d01/ex04/unitests/test_log/one_line_file @@ -0,0 +1 @@ + diff --git a/d01/ex04/unitests/test_log/one_line_file.replace b/d01/ex04/unitests/test_log/one_line_file.replace new file mode 100644 index 0000000..b6fc4c6 --- /dev/null +++ b/d01/ex04/unitests/test_log/one_line_file.replace @@ -0,0 +1 @@ +hello \ No newline at end of file diff --git a/d01/ex04/unitests/test_log/replace_one_character b/d01/ex04/unitests/test_log/replace_one_character new file mode 100644 index 0000000..922f88c --- /dev/null +++ b/d01/ex04/unitests/test_log/replace_one_character @@ -0,0 +1 @@ +....................................................; diff --git a/d01/ex04/unitests/test_log/replace_one_character.replace b/d01/ex04/unitests/test_log/replace_one_character.replace new file mode 100644 index 0000000..d3b95af --- /dev/null +++ b/d01/ex04/unitests/test_log/replace_one_character.replace @@ -0,0 +1 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++++; diff --git a/d01/ex04/unitests/test_log/replace_two_characters b/d01/ex04/unitests/test_log/replace_two_characters new file mode 100644 index 0000000..0880dee --- /dev/null +++ b/d01/ex04/unitests/test_log/replace_two_characters @@ -0,0 +1,2 @@ +...................................................; +. . . . . . . . . . . . . . . . . . . . . . . . . .; diff --git a/d01/ex04/unitests/test_log/replace_two_characters.replace b/d01/ex04/unitests/test_log/replace_two_characters.replace new file mode 100644 index 0000000..80f497e --- /dev/null +++ b/d01/ex04/unitests/test_log/replace_two_characters.replace @@ -0,0 +1,2 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++.; +. . . . . . . . . . . . . . . . . . . . . . . . . .; diff --git a/d01/ex04/unitests/test_log/special_character_' b/d01/ex04/unitests/test_log/special_character_' new file mode 100644 index 0000000..05ee8e4 --- /dev/null +++ b/d01/ex04/unitests/test_log/special_character_' @@ -0,0 +1,27 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why + +You have to go out of my door +And leave just like you did before +I know I said that I was sure +But rich men can't imagine poor. + +One day baby, we'll be old +Oh baby, we'll be old +And think of all the stories that we could have told + +Little me and little you +Kept doing all the things they do +They never really think it through +Like I can never think you're true + +Here I go again - the blame +The guilt, the pain, the hurt, the shame +The founding fathers of our plane +That's stuck in heavy clouds of rain. + +One day baby, we'll be old +Oh baby, we'll be old +And think of all the stories that we could have told diff --git a/d01/ex04/unitests/test_log/special_character_'.replace b/d01/ex04/unitests/test_log/special_character_'.replace new file mode 100644 index 0000000..7292451 --- /dev/null +++ b/d01/ex04/unitests/test_log/special_character_'.replace @@ -0,0 +1,27 @@ +No more tears, my heart is dry +I do000 laugh and I do000 cry +I do000 think about you all the time +But when I do - I wonder why + +You have to go out of my door +And leave just like you did before +I know I said that I was sure +But rich men ca000 imagine poor. + +One day baby, we'll be old +Oh baby, we'll be old +And think of all the stories that we could have told + +Little me and little you +Kept doing all the things they do +They never really think it through +Like I can never think you're true + +Here I go again - the blame +The guilt, the pain, the hurt, the shame +The founding fathers of our plane +That's stuck in heavy clouds of rain. + +One day baby, we'll be old +Oh baby, we'll be old +And think of all the stories that we could have told diff --git a/d01/ex04/unitests/test_log/test10 b/d01/ex04/unitests/test_log/test10 new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test10 @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test10.replace b/d01/ex04/unitests/test_log/test10.replace new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test10.replace @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test11 b/d01/ex04/unitests/test_log/test11 new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test11 @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test11.replace b/d01/ex04/unitests/test_log/test11.replace new file mode 100644 index 0000000..c6854d9 --- /dev/null +++ b/d01/ex04/unitests/test_log/test11.replace @@ -0,0 +1,4 @@ +No more ters, my hert is dry +I don't lugh nd I don't cry +I don't think bout you ll the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test12 b/d01/ex04/unitests/test_log/test12 new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test12 @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test12.replace b/d01/ex04/unitests/test_log/test12.replace new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test12.replace @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test13 b/d01/ex04/unitests/test_log/test13 new file mode 100644 index 0000000..652b428 --- /dev/null +++ b/d01/ex04/unitests/test_log/test13 @@ -0,0 +1,4 @@ +No more tears, my heart is dry +I don't laugh and I don't cry +I don't think about you all the time +But when I do - I wonder why diff --git a/d01/ex04/unitests/test_log/test13.replace b/d01/ex04/unitests/test_log/test13.replace new file mode 100644 index 0000000..e69de29