summary refs log tree commit diff stats
path: root/c/rna-transcription/test/test_rna_transcription.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/rna-transcription/test/test_rna_transcription.c')
-rw-r--r--c/rna-transcription/test/test_rna_transcription.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/c/rna-transcription/test/test_rna_transcription.c b/c/rna-transcription/test/test_rna_transcription.c
new file mode 100644
index 0000000..e7cadc0
--- /dev/null
+++ b/c/rna-transcription/test/test_rna_transcription.c
@@ -0,0 +1,62 @@
+#include "vendor/unity.h"
+#include "../src/rna_transcription.h"
+#include <stdlib.h>
+
+void setUp(void)
+{
+}
+
+void tearDown(void)
+{
+}
+
+static void check_transcription(const char *dna, const char *expected)
+{
+   char *rna = to_rna(dna);
+   TEST_ASSERT_EQUAL_STRING(expected, rna);
+   free(rna);
+}
+
+static void test_empty_rna_sequence(void)
+{
+   check_transcription("", "");
+}
+
+static void test_rna_complement_of_cytosine_is_guanine(void)
+{
+   check_transcription("C", "G");
+}
+
+static void test_rna_complement_of_guanine_is_cytosine(void)
+{
+   check_transcription("G", "C");
+}
+
+static void test_rna_complement_of_thymine_is_adenine(void)
+{
+   check_transcription("T", "A");
+}
+
+static void test_rna_complement_of_adenine_is_uracil(void)
+{
+   check_transcription("A", "U");
+}
+
+static void test_rna_complement(void)
+{
+   check_transcription("ACGTGGTCTTAA", "UGCACCAGAAUU");
+}
+
+int main(void)
+{
+   UnityBegin("test/test_rna_transcription.c");
+
+   RUN_TEST(test_empty_rna_sequence);
+   RUN_TEST(test_rna_complement_of_cytosine_is_guanine);
+   RUN_TEST(test_rna_complement_of_guanine_is_cytosine);
+   RUN_TEST(test_rna_complement_of_thymine_is_adenine);
+   RUN_TEST(test_rna_complement_of_adenine_is_uracil);
+   RUN_TEST(test_rna_complement);
+
+   return UnityEnd();
+}