Sha256: 45adc31d37e25e5531e205c334e814d38de88b6da879210d0711dff91b2dc20a

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

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

void test_abbreviation(char *phrase, char *expected)
{
   char *actual = abbreviate(phrase);
   TEST_ASSERT_EQUAL_STRING(expected, actual);
   free(actual);
}

void test_null_string(void)
{
   char *phrase = NULL;
   char *expected = NULL;
   test_abbreviation(phrase, expected);
}

void test_empty_string(void)
{
   char *phrase = "";
   char *expected = NULL;
   test_abbreviation(phrase, expected);
}

void test_basic_abbreviation(void)
{
   char *phrase = "Portable Network Graphics";
   char *expected = "PNG";
   test_abbreviation(phrase, expected);
}

void test_lower_case_words(void)
{
   char *phrase = "Ruby on Rails";
   char *expected = "ROR";
   test_abbreviation(phrase, expected);
}

void test_punctuation(void)
{
   char *phrase = "First In, First Out";
   char *expected = "FIFO";
   test_abbreviation(phrase, expected);
}

void test_all_caps_words(void)
{
   char *phrase = "PHP: Hypertext Preprocessor";
   char *expected = "PHP";
   test_abbreviation(phrase, expected);
}

void test_non_acronym_all_caps_words(void)
{
   char *phrase = "GNU Image Manipulation Program";
   char *expected = "GIMP";
   test_abbreviation(phrase, expected);
}

void test_hyphenated(void)
{
   char *phrase = "Complementary metal-oxide semiconductor";
   char *expected = "CMOS";
   test_abbreviation(phrase, expected);
}

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

   RUN_TEST(test_basic_abbreviation);
   RUN_TEST(test_null_string);
   RUN_TEST(test_empty_string);
   RUN_TEST(test_lower_case_words);
   RUN_TEST(test_punctuation);
   RUN_TEST(test_all_caps_words);
   RUN_TEST(test_non_acronym_all_caps_words);
   RUN_TEST(test_hyphenated);

   UnityEnd();
   return 0;
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
trackler-2.2.1.42 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.41 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.40 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.39 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.38 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.37 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.36 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.35 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.34 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.33 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.32 tracks/c/exercises/acronym/test/test_acronym.c