Sha256: 070edbb2e62bd90c185e45979b9ceec5a75eac329c4a60b3ba29e071bbf2434e

Contents?: true

Size: 1.44 KB

Versions: 46

Compression:

Stored size: 1.44 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_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_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

46 entries across 46 versions & 1 rubygems

Version Path
trackler-2.2.1.31 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.30 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.29 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.28 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.27 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.26 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.25 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.24 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.23 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.22 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.21 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.20 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.19 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.18 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.17 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.16 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.15 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.14 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.13 tracks/c/exercises/acronym/test/test_acronym.c
trackler-2.2.1.12 tracks/c/exercises/acronym/test/test_acronym.c