d01 ex04 erreur saute des find possibles
This commit is contained in:
@@ -22,12 +22,17 @@ void Sed::replace() {
|
||||
{
|
||||
if (str[0] == this->_find[0])
|
||||
{
|
||||
tmp = str[0];
|
||||
file.get(str, len, EOF);
|
||||
if (this->_find.compare(1, len - 1, str) == 0)
|
||||
if (len == 1)
|
||||
new_file << this->_replacement;
|
||||
else
|
||||
new_file << tmp << str;
|
||||
{
|
||||
tmp = str[0];
|
||||
file.get(str, len, EOF);
|
||||
if (this->_find.compare(1, len - 1, str) == 0)
|
||||
new_file << this->_replacement;
|
||||
else
|
||||
new_file << tmp << str;
|
||||
}
|
||||
}
|
||||
else
|
||||
new_file << str;
|
||||
|
||||
0
d01/ex04/ldksliejf.replace
Normal file
0
d01/ex04/ldksliejf.replace
Normal file
BIN
d01/ex04/sed
BIN
d01/ex04/sed
Binary file not shown.
1
d01/ex04/test_log/test1
Normal file
1
d01/ex04/test_log/test1
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
5
d01/ex04/test_log/test2
Normal file
5
d01/ex04/test_log/test2
Normal file
@@ -0,0 +1,5 @@
|
||||
ce fichier
|
||||
contient
|
||||
plusieurs lignes
|
||||
les unes au dessus des autres
|
||||
youhouuu ioieux
|
||||
1
d01/ex04/test_log/test3
Normal file
1
d01/ex04/test_log/test3
Normal file
@@ -0,0 +1 @@
|
||||
....................................................;
|
||||
2
d01/ex04/test_log/test4
Normal file
2
d01/ex04/test_log/test4
Normal file
@@ -0,0 +1,2 @@
|
||||
...................................................;
|
||||
. . . . . . . . . . . . . . . . . . . . . . . . . .;
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd $(dirname $0)
|
||||
source ./colors.sh
|
||||
|
||||
mkdir -p test_log
|
||||
@@ -13,9 +14,9 @@ mkdir -p test_log
|
||||
OUTPUT=$( cat $TESTNAME.replace )
|
||||
if [ "$OUTPUT" == "$RESULT" ]
|
||||
then
|
||||
echo -e $B_GREEN"test1 success"$ENDCO
|
||||
echo -e $B_GREEN"$TESTNAME success"$ENDCO
|
||||
else
|
||||
echo -e $B_RED"test1 faillure"$ENDCO
|
||||
echo -e $B_RED"$TESTNAME faillure"$ENDCO
|
||||
fi
|
||||
|
||||
mv $TESTNAME $TESTNAME.replace ./test_log
|
||||
@@ -65,7 +66,7 @@ EOF
|
||||
)
|
||||
run_tests
|
||||
|
||||
# TEST 3 ########################################
|
||||
# TEST 4 ########################################
|
||||
TESTNAME="test4"
|
||||
FIND=".."
|
||||
REPLACEMENT="++"
|
||||
@@ -81,3 +82,17 @@ EOF
|
||||
)
|
||||
run_tests
|
||||
|
||||
# TEST 5 ########################################
|
||||
TESTNAME="test5"
|
||||
FIND="mdr"
|
||||
REPLACEMENT="|||"
|
||||
CONTENT=$(cat << EOF
|
||||
test de mmdr foubar
|
||||
EOF
|
||||
)
|
||||
RESULT=$(cat << EOF
|
||||
test de m||| foubar
|
||||
EOF
|
||||
)
|
||||
run_tests
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
hello
|
||||
hello
|
||||
|
||||
@@ -1 +1 @@
|
||||
+
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++;
|
||||
|
||||
1
d01/ex04/unitests/test_log/test5
Normal file
1
d01/ex04/unitests/test_log/test5
Normal file
@@ -0,0 +1 @@
|
||||
test de mmdr foubar
|
||||
1
d01/ex04/unitests/test_log/test5.replace
Normal file
1
d01/ex04/unitests/test_log/test5.replace
Normal file
@@ -0,0 +1 @@
|
||||
test de mmdr foubar
|
||||
Reference in New Issue
Block a user