From d650c6d7558154d7f6f24740eeb8a5257749c229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Mon, 6 May 2024 23:20:50 -0700 Subject: [PATCH] Sync hamming tests and update stub (#368) --- exercises/practice/hamming/hamming-test.el | 48 ++++++++++------------ exercises/practice/hamming/hamming.el | 7 +++- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/exercises/practice/hamming/hamming-test.el b/exercises/practice/hamming/hamming-test.el index 0cac98e6..9fb22e67 100644 --- a/exercises/practice/hamming/hamming-test.el +++ b/exercises/practice/hamming/hamming-test.el @@ -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 + diff --git a/exercises/practice/hamming/hamming.el b/exercises/practice/hamming/hamming.el index 6a0bc5d1..c14a52fe 100644 --- a/exercises/practice/hamming/hamming.el +++ b/exercises/practice/hamming/hamming.el @@ -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