1
exercism fetch nim nucleotide-count

nucleotide_count_test.nim

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
import tables
import unittest
import nucleotide_count

test "count empty string":
  check count('A', "") == 0

test "count repetitive cytosine":
  check count('C', "CCCCC") == 5

test "count only thymine":
  check count('T', "GGGGGTAACCCGG") == 1

test "count_dna empty":
  check len(count_dna("")) == 0

test "count_dna only guanine":
  let counts = count_dna("GGGGGGGG")
  check counts['G'] == 8

test "count_dna counts all":
  let counts = count_dna("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")
  check counts['A'] == 20
  check counts['C'] == 12
  check counts['T'] == 21
  check counts['G'] == 17