Skip to content

Commit

Permalink
Sync hamming tests (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras authored Apr 24, 2024
1 parent a7ef62a commit 644aa3e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/hamming/.meta/example.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"
function! Distance(strand1, strand2)
if len(a:strand1) != len(a:strand2)
throw 'left and right strands must be of equal length'
throw 'strands must be of equal length'
endif
let distance = 0
for i in range(len(a:strand1))
Expand Down
65 changes: 38 additions & 27 deletions exercises/practice/hamming/hamming.vader
Original file line number Diff line number Diff line change
@@ -1,47 +1,58 @@
"
" Version: 2.2.0
"

Execute (empty strands):
let strand1 = ""
let strand2 = ""
let expected = 0
AssertEqual expected, Distance(strand1, strand2)
let g:strand1 = ""
let g:strand2 = ""
let g:expected = 0
AssertEqual g:expected, Distance(g:strand1, g:strand2)

Execute (single letter identical strands):
let strand1 = "A"
let strand2 = "A"
let expected = 0
AssertEqual expected, Distance(strand1, strand2)
let g:strand1 = "A"
let g:strand2 = "A"
let g:expected = 0
AssertEqual g:expected, Distance(g:strand1, g:strand2)

Execute (single letter different strands):
let strand1 = "G"
let strand2 = "T"
let expected = 1
AssertEqual expected, Distance(strand1, strand2)
let g:strand1 = "G"
let g:strand2 = "T"
let g:expected = 1
AssertEqual g:expected, Distance(g:strand1, g:strand2)

Execute (long identical strands):
let strand1 = "GGACTGAAATCTG"
let strand2 = "GGACTGAAATCTG"
let expected = 0
AssertEqual expected, Distance(strand1, strand2)
let g:strand1 = "GGACTGAAATCTG"
let g:strand2 = "GGACTGAAATCTG"
let g:expected = 0
AssertEqual g:expected, Distance(g:strand1, g:strand2)

Execute (long different strands):
let strand1 = "GGACGGATTCTG"
let strand2 = "AGGACGGATTCT"
let expected = 9
AssertEqual expected, Distance(strand1, strand2)
let g:strand1 = "GGACGGATTCTG"
let g:strand2 = "AGGACGGATTCT"
let g:expected = 9
AssertEqual g:expected, Distance(g:strand1, g:strand2)

Execute (disallow first strand longer):
let g:strand1 = "AATG"
let g:strand2 = "AAA"
let expected = 'left and right strands must be of equal length'
let g:expected = "strands must be of equal length"
AssertThrows call Distance(g:strand1, g:strand2)
AssertEqual expected, g:vader_exception
AssertEqual g:expected, g:vader_exception

Execute (disallow second strand longer):
let g:strand1 = "ATA"
let g:strand2 = "AGTG"
let expected = 'left and right strands must be of equal length'
let g:expected = "strands must be of equal length"
AssertThrows call Distance(g:strand1, g:strand2)
AssertEqual expected, g:vader_exception
AssertEqual g:expected, g:vader_exception

Execute (disallow empty first strand):
let g:strand1 = ""
let g:strand2 = "G"
let g:expected = "strands must be of equal length"
AssertThrows call Distance(g:strand1, g:strand2)
AssertEqual g:expected, g:vader_exception

Execute (disallow empty second strand):
let g:strand1 = "G"
let g:strand2 = ""
let g:expected = "strands must be of equal length"
AssertThrows call Distance(g:strand1, g:strand2)
AssertEqual g:expected, g:vader_exception
2 changes: 1 addition & 1 deletion exercises/practice/hamming/hamming.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"
" If the lengths of the strands don't match, throw this exception:
"
" 'left and right strands must be of equal length'
" 'strands must be of equal length'
"
function! Distance(strand1, strand2)

Expand Down

0 comments on commit 644aa3e

Please sign in to comment.