Skip to content

Commit

Permalink
bash tests - replace echo with printf (newline problems)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmikk committed Oct 27, 2024
1 parent e7d1a43 commit 95f202f
Showing 1 changed file with 7 additions and 48 deletions.
55 changes: 7 additions & 48 deletions test/test2_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ total_tests=0
# Test basic usage
function test_basic_usage {
result=$(../seqhasher test2.fasta -)
expected=$(cat <<EOF
>test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1
AAAA
>test2.fasta;f74673f038f3657adfa522aa370b5cd161dec321;seq2
ACTG
>test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3
AAAA
EOF
)
expected=$(printf ">test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1\nAAAA\n>test2.fasta;65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2\nACTG\n>test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3\nAAAA\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'Basic usage' test failed\e[0m"
Expand All @@ -30,15 +22,7 @@ EOF
# Test custom name
function test_custom_name {
result=$(../seqhasher --name "custom_name" test2.fasta -)
expected=$(cat <<EOF
>custom_name;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1
AAAA
>custom_name;65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2
ACTG
>custom_name;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3
AAAA
EOF
)
expected=$(printf ">custom_name;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1\nAAAA\n>custom_name;65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2\nACTG\n>custom_name;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3\nAAAA\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'Custom name' test failed\e[0m"
Expand All @@ -51,12 +35,7 @@ EOF
# Test headers only
function test_headers_only {
result=$(../seqhasher --headersonly test2.fasta -)
expected=$(cat <<EOF
test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1
test2.fasta;65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2
test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3
EOF
)
expected=$(printf "test2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1\ntest2.fasta;65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2\ntest2.fasta;e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'Headers only' test failed\e[0m"
Expand All @@ -69,12 +48,7 @@ EOF
# Test no filename
function test_no_filename {
result=$(../seqhasher --headersonly --nofilename test2.fasta -)
expected=$(cat <<EOF
e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1
65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2
e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3
EOF
)
expected=$(printf "e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1\n65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2\ne2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'No filename' test failed\e[0m"
Expand All @@ -87,12 +61,7 @@ EOF
# Test xxHash and case-sensitive
function test_xxhash_case_sensitive {
result=$(../seqhasher --headersonly --nofilename --hash xxhash --casesensitive test2.fasta -)
expected=$(cat <<EOF
cf40b5b72bc43e77;seq1
704b34bf20faedf2;seq2
42a70d1abf84bf32;seq3
EOF
)
expected=$(printf "cf40b5b72bc43e77;seq1\n704b34bf20faedf2;seq2\n42a70d1abf84bf32;seq3\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'xxHash and case-sensitive' test failed\e[0m"
Expand All @@ -105,12 +74,7 @@ EOF
# Test multiple hashes
function test_multiple_hashes {
result=$(../seqhasher --headersonly --nofilename --hash sha1,xxhash --casesensitive test2.fasta -)
expected=$(cat <<EOF
e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;cf40b5b72bc43e77;seq1
65c89f59d38cdbf90dfaf0b0a6884829df8396b0;704b34bf20faedf2;seq2
70c881d4a26984ddce795f6f71817c9cf4480e79;42a70d1abf84bf32;seq3
EOF
)
expected=$(printf "e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;cf40b5b72bc43e77;seq1\n65c89f59d38cdbf90dfaf0b0a6884829df8396b0;704b34bf20faedf2;seq2\n70c881d4a26984ddce795f6f71817c9cf4480e79;42a70d1abf84bf32;seq3\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'Multiple hashes' test failed\e[0m"
Expand All @@ -124,12 +88,7 @@ EOF
function test_compressed_files {
for ext in bz2 gz xz zst; do
result=$(../seqhasher --headersonly --nofilename test2.fasta.$ext -)
expected=$(cat <<EOF
e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1
65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2
e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3
EOF
)
expected=$(printf "e2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq1\n65c89f59d38cdbf90dfaf0b0a6884829df8396b0;seq2\ne2512172abf8cc9f67fdd49eb6cacf2df71bbad3;seq3\n")
((total_tests++))
if [[ "$result" != "$expected" ]]; then
echo -e "\e[31m'Compressed file' test failed for .$ext\e[0m"
Expand Down

0 comments on commit 95f202f

Please sign in to comment.