Skip to content

Commit

Permalink
Sync hamming tests and update stub (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras authored May 7, 2024
1 parent d4032e1 commit d650c6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
48 changes: 22 additions & 26 deletions exercises/practice/hamming/hamming-test.el
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
;;; hamming-test.el --- Tests for hamming (exercism) -*- lexical-binding: t; -*-
;;; hamming-test.el --- Hamming (exercism) -*- lexical-binding: t; -*-

;;; Commentary:
;; Common test data version: 2.0.1 f79dfd7

;;; Code:


(load-file "hamming.el")
(declare-function hamming-distance "hamming.el" (dna1 dna2))


(ert-deftest empty-strands ()
(should (= 0 (hamming-distance "" ""))))

(ert-deftest identical-strands ()

(ert-deftest single-letter-identical-strands ()
(should (= 0 (hamming-distance "A" "A"))))


(ert-deftest single-letter-different-strands ()
(should (= 1 (hamming-distance "G" "T"))))


(ert-deftest long-identical-strands ()
(should (= 0 (hamming-distance "GGACTGA" "GGACTGA"))))
(should (= 0 (hamming-distance "GGACTGAAATCTG" "GGACTGAAATCTG"))))

(ert-deftest complete-distance-in-single-nucleotide-strands ()
(should (= 1 (hamming-distance "A" "G"))))
(ert-deftest long-different-strands ()
(should (= 9 (hamming-distance "GGACGGATTCTG" "AGGACGGATTCT"))))

(ert-deftest complete-distance-in-small-strands ()
(should (= 2 (hamming-distance "AG" "CT"))))

(ert-deftest small-distance-in-small-strands ()
(should (= 1 (hamming-distance "AT" "CT"))))
(ert-deftest disallow-first-strand-longer ()
(should-error (hamming-distance "AATG" "AAA")))

(ert-deftest small-distance ()
(should (= 1 (hamming-distance "GGACG" "GGTCG"))))

(ert-deftest small-distance-in-long-strands ()
(should (= 2 (hamming-distance "ACCAGGG" "ACTATGG"))))
(ert-deftest disallow-second-strand-longer ()
(should-error (hamming-distance "ATA" "AGTG")))

(ert-deftest non-unique-character-in-first-strand ()
(should (= 1 (hamming-distance "AAA" "AAG"))))

(ert-deftest same-nucleotides-in-different-positions ()
(should (= 2 (hamming-distance "TAG" "GAT"))))
(ert-deftest disallow-empty-first-strand ()
(should-error (hamming-distance "" "G")))

(ert-deftest large-distance ()
(should (= 4 (hamming-distance "GATACA" "GCATAA"))))

(ert-deftest large-distance-in-off-by-one-strand ()
(should (= 9 (hamming-distance "GGACGGATTCTG" "AGGACGGATTCT"))))

(ert-deftest disallow-first-strand-longer ()
(should-error (hamming-distance "AATG" "AAA")))
(ert-deftest disallow-empty-second-strand ()
(should-error (hamming-distance "G" "")))

(ert-deftest disallow-second-strand-longer ()
(should-error (hamming-distance "ATA" "AGTG")))

(provide 'hamming-test)
;;; hamming-test.el ends here

7 changes: 5 additions & 2 deletions exercises/practice/hamming/hamming.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

;;; Commentary:

;;; Code:


(defun hamming-distance (dna1 dna2)
;;; Code:
)
(error "Delete this S-Expression and write your own implementation"))


(provide 'hamming)
;;; hamming.el ends here

0 comments on commit d650c6d

Please sign in to comment.