Sha256: 51f5e934ab6377639082c26cc8228ae3514f0c9868e7c9367850e6c578e90c7a

Contents?: true

Size: 1.35 KB

Versions: 163

Compression:

Stored size: 1.35 KB

Contents

#include "vendor/unity.h"
#include "../src/rna_transcription.h"
#include <stdlib.h>

void test_transcription(const char *dna, const char *expected)
{
   char *rna = to_rna(dna);
   TEST_ASSERT_EQUAL_STRING(expected, rna);
   free(rna);
}

void test_failure(const char *dna)
{
   TEST_ASSERT_NULL(to_rna(dna));
}

void test_transcribes_G_to_C(void)
{
   test_transcription("G", "C");
}

void test_transcribes_C_to_G(void)
{
   test_transcription("C", "G");
}

void test_transcribes_T_to_A(void)
{
   test_transcription("T", "A");
}

void test_transcribes_A_to_U(void)
{
   test_transcription("A", "U");
}

void test_transcribes_all_occurrences(void)
{
   test_transcription("ACGTGGTCTTAA", "UGCACCAGAAUU");
}

void test_handle_invalid_nucleotide(void)
{
   test_failure("U");
}

void test_handle_completely_invalid_input(void)
{
   test_failure("XXX");
}

void test_handle_partially_invalid_input(void)
{
   test_failure("ACGTXXXCTTAA");
}

int main(void)
{
   UnityBegin("test/test_rna_transcription.c");

   RUN_TEST(test_transcribes_G_to_C);
   RUN_TEST(test_transcribes_C_to_G);
   RUN_TEST(test_transcribes_T_to_A);
   RUN_TEST(test_transcribes_A_to_U);
   RUN_TEST(test_transcribes_all_occurrences);
   RUN_TEST(test_handle_invalid_nucleotide);
   RUN_TEST(test_handle_completely_invalid_input);
   RUN_TEST(test_handle_partially_invalid_input);

   UnityEnd();
   return 0;
}

Version data entries

163 entries across 163 versions & 1 rubygems

Version Path
trackler-2.2.1.42 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.41 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.40 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.39 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.38 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.37 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.36 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.35 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.34 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.33 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.32 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.31 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.30 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.29 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.28 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.27 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.26 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.25 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.24 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.2.1.23 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c