1
exercism fetch scheme nucleotide-count

nucleotide-count-test.scm

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
;; Load SRFI-64 lightweight testing specification
(use-modules (srfi srfi-64))

;; Suppress log file output. To write logs, comment out the following line:
(module-define! (resolve-module '(srfi srfi-64)) 'test-log-to-file #f)

(add-to-load-path (dirname (current-filename)))
(use-modules (nucleotide-count))



(test-begin "nucleotide-count")

(test-eqv "empty-dna-strand-has-no-adenine"
          0
          (dna-count #\A ""))

(test-equal "empty-dna-strand-has-no-nucleotides"
            '((#\A . 0) (#\C . 0) (#\G . 0) (#\T . 0))
            (nucleotide-counts ""))

(test-eqv "repetitive-cytosine-gets-counted"
          5
          (dna-count #\C "CCCCC"))

(test-equal "repetitive-sequence-has-only-guanine"
            '((#\A . 0) (#\C . 0) (#\G . 8) (#\T . 0))
            (nucleotide-counts "GGGGGGGG"))

(test-eqv "counts-only-thymine"
          1
          (dna-count #\T "GGGGGTAACCCGG"))

(test-error "validates-nucleotides"
            #t
            (dna-count #\X "ACGT")
            )

(test-equal "counts-all-nucleotides"
            '((#\A . 20) (#\C . 12) (#\G . 17) (#\T . 21))
            (nucleotide-counts
             "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"))

(test-end "nucleotide-count")