1
exercism fetch lfe nucleotide-count

test/dna-tests.lfe

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
(defmodule dna-tests
  (behaviour ltest-unit)
  (export all))

(include-lib "ltest/include/ltest-macros.lfe")

(deftest empty-dna-sting-has-no-adenine
  (is-equal 0 (dna:count "" "A")))

(deftest repetitive-cytosine-gets-counted
  (is-equal 5 (dna:count "CCCCC" "C")))

(deftest counts-only-thymine
  (is-equal 1 (dna:count "GGGGGTAACCCGG" "T")))

(deftest validates-nucleotides
  (is-error _ (dna:count "GACT" "X")))

(deftest validates-strand
  (is-error _ (dna:count "GACYT" "G")))

(deftest empty-dna-string-has-no-nucleotides
  (is-equal `(#("A" 0) #("C" 0) #("G" 0) #("T" 0))
            (dna:nucleotide-counts "")))

(deftest repetitive-sequence-has-only-guanine
  (is-equal `(#("A" 0) #("C" 0) #("G" 8) #("T" 0))
            (dna:nucleotide-counts "GGGGGGGG")))

(deftest counts-all-nucleotides
  (is-equal
    `(#("A" 20) #("C" 12) #("G" 17) #("T" 21))
    (dna:nucleotide-counts
      "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")))