exercism

Exercism solutions.
git clone git://code.dwrz.net/exercism
Log | Files | Refs

hamming-test.el (1609B)


      1 ;;; hamming-test.el --- Tests for hamming (exercism)
      2 
      3 ;;; Commentary:
      4 ;; Common test data version: 2.0.1 f79dfd7
      5 
      6 ;;; Code:
      7 
      8 (load-file "hamming.el")
      9 
     10 (declare-function hamming-distance "hamming.el")
     11 
     12 (ert-deftest empty-strands ()
     13   (should (= 0 (hamming-distance "" ""))))
     14 
     15 (ert-deftest identical-strands ()
     16   (should (= 0 (hamming-distance "A" "A"))))
     17 
     18 (ert-deftest long-identical-strands ()
     19   (should (= 0 (hamming-distance "GGACTGA" "GGACTGA"))))
     20 
     21 (ert-deftest complete-distance-in-single-nucleotide-strands ()
     22   (should (= 1 (hamming-distance "A" "G"))))
     23 
     24 (ert-deftest complete-distance-in-small-strands ()
     25   (should (= 2 (hamming-distance "AG" "CT"))))
     26 
     27 (ert-deftest small-distance-in-small-strands ()
     28   (should (= 1 (hamming-distance "AT" "CT"))))
     29 
     30 (ert-deftest small-distance ()
     31   (should (= 1 (hamming-distance "GGACG" "GGTCG"))))
     32 
     33 (ert-deftest small-distance-in-long-strands ()
     34   (should (= 2 (hamming-distance "ACCAGGG" "ACTATGG"))))
     35 
     36 (ert-deftest non-unique-character-in-first-strand ()
     37   (should (= 1 (hamming-distance "AAA" "AAG"))))
     38 
     39 (ert-deftest same-nucleotides-in-different-positions ()
     40   (should (= 2 (hamming-distance "TAG" "GAT"))))
     41 
     42 (ert-deftest large-distance ()
     43   (should (= 4 (hamming-distance "GATACA" "GCATAA"))))
     44 
     45 (ert-deftest large-distance-in-off-by-one-strand ()
     46   (should (= 9 (hamming-distance "GGACGGATTCTG" "AGGACGGATTCT"))))
     47 
     48 (ert-deftest disallow-first-strand-longer ()
     49   (should-error (hamming-distance "AATG" "AAA")))
     50 
     51 (ert-deftest disallow-second-strand-longer ()
     52   (should-error (hamming-distance "ATA" "AGTG")))
     53 
     54 (provide 'hamming-test)
     55 ;;; hamming-test.el ends here