Skip to content

Commit

Permalink
sed のテスト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
515hikaru committed Apr 18, 2020
1 parent 5eea076 commit e082d2b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,6 +8,7 @@ www-data/*.jp
www-data/wget-log*
*.jp
grep_*
!grep_test.sh
*.swp
*.tmp
*.log
Expand Down
44 changes: 44 additions & 0 deletions test/grep_test.sh
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

. ./crawler/grep.sh

# test sanitize_grep_result
## remove whitespace chars
input="foo.html:あいうえお かきくけこ さしすせそ たちつてと"
result=$(echo $input | sanitize_grep_result)
echo $result
expect="foo.html:あいうえおかきくけこさしすせそたちつてと"
echo $expect
if [ "$result" = "$expect" ]; then
echo "passed"
else
echo "failed"
exit 1
fi

## remove too long line
input="foo.html:$(seq 100 | xargs)"
result=$(echo $input | sanitize_grep_result)
echo $result
expect=""
echo $expect
if [ "$result" = "$expect" ]; then
echo "passed"
else
echo "failed"
exit 1
fi

## sanitize HTML tags
input="foo.html:<p><a href=\"bar.html\">テキストテキスト<br>テキスト</a></p>"
result=$(echo $input | sanitize_grep_result)
echo $result
expect="foo.html:テキストテキストテキスト"
echo $expect
if [ "$result" = "$expect" ]; then
echo "passed"
else
echo "failed"
exit 1
fi

0 comments on commit e082d2b

Please sign in to comment.