fortrangoingonforty/ferp / 7614d9b

Browse files

update tests files

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7614d9b94e0a3fd41fb020b5849e11277f2c0995
Parents
c5ced7d
Tree
7491fb1

2 changed files

StatusFile+-
M tests/fixtures/multifile3.txt 1 1
M tests/integration_test.sh 10 5
tests/fixtures/multifile3.txtmodified
@@ -1,3 +1,3 @@
1
-file3 no matches here
1
+file3 no hits here
22
 file3 nothing to see
33
 file3 all clear
tests/integration_test.shmodified
@@ -930,7 +930,8 @@ test_line_prefix() {
930930
     should_run "$name" && {
931931
         log_test "$name"
932932
         local out
933
-        out=$("$FERP" -n "line 1" "$FIXTURES/numbers.txt")
933
+        # Use -x for exact line match to avoid "line 10" also matching
934
+        out=$("$FERP" -nx "line 1" "$FIXTURES/numbers.txt")
934935
         if [[ "$out" == "1:line 1" ]]; then
935936
             pass "$name"
936937
         else
@@ -955,7 +956,8 @@ test_line_prefix() {
955956
     should_run "$name" && {
956957
         log_test "$name"
957958
         local out
958
-        out=$("$FERP" -b "line 1" "$FIXTURES/numbers.txt")
959
+        # Use -x for exact line match to avoid "line 10" also matching
960
+        out=$("$FERP" -bx "line 1" "$FIXTURES/numbers.txt")
959961
         if [[ "$out" == "0:line 1" ]]; then
960962
             pass "$name"
961963
         else
@@ -992,7 +994,8 @@ test_line_prefix() {
992994
     should_run "$name" && {
993995
         log_test "$name"
994996
         local out
995
-        out=$("$FERP" --byte-offset "line 1" "$FIXTURES/numbers.txt")
997
+        # Use -x for exact line match
998
+        out=$("$FERP" --byte-offset -x "line 1" "$FIXTURES/numbers.txt")
996999
         if [[ "$out" == "0:line 1" ]]; then
9971000
             pass "$name"
9981001
         else
@@ -1055,7 +1058,8 @@ test_line_prefix() {
10551058
     should_run "$name" && {
10561059
         log_test "$name"
10571060
         local out
1058
-        out=$("$FERP" -HZ "hello" "$FIXTURES/simple.txt" | head -1 | od -c | head -1)
1061
+        # Check that null byte exists between filename and content
1062
+        out=$("$FERP" -HZ "hello" "$FIXTURES/simple.txt" | head -1 | od -c)
10591063
         if echo "$out" | grep -q '\\0'; then
10601064
             pass "$name"
10611065
         else
@@ -1067,7 +1071,8 @@ test_line_prefix() {
10671071
     should_run "$name" && {
10681072
         log_test "$name"
10691073
         local out
1070
-        out=$("$FERP" -H --null "hello" "$FIXTURES/simple.txt" | head -1 | od -c | head -1)
1074
+        # Check that null byte exists between filename and content
1075
+        out=$("$FERP" -H --null "hello" "$FIXTURES/simple.txt" | head -1 | od -c)
10711076
         if echo "$out" | grep -q '\\0'; then
10721077
             pass "$name"
10731078
         else