summaryrefslogtreecommitdiff
path: root/exercism/emacs-lisp/hamming/hamming-test.el
blob: fb9be4615570ef1d8946addfd7c54e9ae5f3de54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;;; hamming-test.el --- Tests for hamming (exercism)

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

;;; Code:

(load-file "hamming.el")

(declare-function hamming-distance "hamming.el")

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

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

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

(ert-deftest complete-distance-in-single-nucleotide-strands ()
  (should (= 1 (hamming-distance "A" "G"))))

(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 small-distance ()
  (should (= 1 (hamming-distance "GGACG" "GGTCG"))))

(ert-deftest small-distance-in-long-strands ()
  (should (= 2 (hamming-distance "ACCAGGG" "ACTATGG"))))

(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 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-second-strand-longer ()
  (should-error (hamming-distance "ATA" "AGTG")))

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