blob: 7691fb78ac7e50f89ade1c7d5aebdbc22bd06e3b (
plain) (
blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "vendor/unity.h"
#include "../src/nucleotide_count.h"
#include <stdlib.h>
#include <string.h>
void setUp(void)
{
}
void tearDown(void)
{
}
#include <stdio.h>
static void test_strand_count(const char *dna_strand, const char *expected)
{
char *actual_count = count(dna_strand);
TEST_ASSERT_TRUE(strcmp(actual_count, expected) == 0);
free(actual_count);
}
static void test_empty_strand(void)
{
const char *dna_strand = "";
const char *expected = "A:0 C:0 G:0 T:0";
test_strand_count(dna_strand, expected);
}
static void test_repeated_nucleotide(void)
{
const char *dna_strand = "GGGGGGG";
const char *expected = "A:0 C:0 G:7 T:0";
test_strand_count(dna_strand, expected);
}
static void test_multiple_nucleotides(void)
{
const char *dna_strand =
"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC";
const char *expected = "A:20 C:12 G:17 T:21";
test_strand_count(dna_strand, expected);
}
static void test_invalid_nucleotide(void)
{
const char *dna_strand = "AGXXACT";
const char *expected = "";
test_strand_count(dna_strand, expected);
}
int main(void)
{
UnityBegin("test/test_nucleotide_count.c");
RUN_TEST(test_empty_strand);
RUN_TEST(test_repeated_nucleotide);
RUN_TEST(test_multiple_nucleotides);
RUN_TEST(test_invalid_nucleotide);
return UnityEnd();
}
|