-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from Khronos31/encode
unko.encodeを少し最適化
- Loading branch information
Showing
4 changed files
with
119 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bats | ||
source functions.sh | ||
|
||
readonly TARGET_COMMAND="../bin/unko.encode" | ||
|
||
@test "-h でヘルプを出力する" { | ||
run "$TARGET_COMMAND" -h | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
[[ "${lines[0]}" =~ ^Usage:.* ]] | ||
coverage "$TARGET_COMMAND" -h | ||
} | ||
|
||
@test "--help でヘルプを出力する" { | ||
run "$TARGET_COMMAND" --help | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
[[ "${lines[0]}" =~ ^Usage:.* ]] | ||
coverage "$TARGET_COMMAND" --help | ||
} | ||
|
||
@test '引数なしのときは標準入力をエンコード' { | ||
run "$TARGET_COMMAND" <<< うんこ | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
[ "${lines[0]}" = "ウンウこうんこう💩ウンウこうこここウウンウこうんここウうんこ" ] | ||
coverage "$TARGET_COMMAND" <<< うんこ | ||
} | ||
|
||
@test '-d で標準入力をデコード { | ||
run "$TARGET_COMMAND" -d <<< ウンウこうんこう💩ウンウこうこここウウンウこうんここウうんこ | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
[ "${lines[0]}" = "うんこ" ] | ||
coverage "$TARGET_COMMAND" -d <<< ウンウこうんこう💩ウンウこうこここウウンウこうんここウうんこ | ||
} | ||
@test '--decode で標準入力をデコード { | ||
run "$TARGET_COMMAND" --decode <<< ウンウこうんこう💩ウンウこうこここウウンウこうんここウうんこ | ||
echo "$output" | ||
[ "$status" -eq 0 ] | ||
[ "${lines[0]}" = "うんこ" ] | ||
coverage "$TARGET_COMMAND" --decode <<< ウンウこうんこう💩ウンウこうこここウウンウこうんここウうんこ | ||
} | ||
|
||
@test 'ファイルが存在しない場合エラー' { | ||
export LANG=ja_JP.UTF-8 | ||
run "$TARGET_COMMAND" うんこ | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "${lines[0]}" =~ .*そのようなファイルやディレクトリはありません ]] | ||
coverage LANG=ja_JP.UTF-8 "$TARGET_COMMAND" うんこ | ||
} | ||
|
||
@test 'ディレクトリの場合エラー' { | ||
export LANG=ja_JP.UTF-8 | ||
run "$TARGET_COMMAND" . | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "${lines[0]}" =~ .*ディレクトリです ]] | ||
coverage LANG=ja_JP.UTF-8 "$TARGET_COMMAND" . | ||
} | ||
|
||
@test 'ファイルが存在しない場合エラー(英語版)' { | ||
export LANG=en_US.UTF-8 | ||
run "$TARGET_COMMAND" うんこ | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "${lines[0]}" =~ .*"No such file or directory" ]] | ||
coverage LANG=en_US.UTF-8 "$TARGET_COMMAND" うんこ | ||
} | ||
|
||
@test 'ディレクトリの場合エラー(英語版)' { | ||
export LANG=en_US.UTF-8 | ||
run "$TARGET_COMMAND" . | ||
echo "$output" | ||
[ "$status" -eq 1 ] | ||
[[ "${lines[0]}" =~ .*"Is a directory" ]] | ||
coverage LANG=en_US.UTF-8 "$TARGET_COMMAND" . | ||
} |