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.1.0.4 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.1.0.3 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.1.0.2 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.1.0.1 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.1.0.0 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.55 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.54 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.53 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.52 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.51 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.50 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.49 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.48 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.47 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.46 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.45 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.44 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.43 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.42 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c
trackler-2.0.8.41 tracks/c/exercises/rna-transcription/test/test_rna_transcription.c