summary refs log tree commit diff stats
path: root/c/isogram/test/test_isogram.c
blob: 5671338b21206587101057ca2ea3c1a4b3785fa9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "vendor/unity.h"
#include "../src/isogram.h"
#include <stdlib.h>

void setUp(void)
{
}

void tearDown(void)
{
}

static void test_empty_string(void)
{
   TEST_ASSERT_TRUE(is_isogram(""));
}

static void test_null(void)
{
   TEST_ASSERT_FALSE(is_isogram(NULL));
}

static void test_isogram_with_only_lower_case_characters(void)
{
   TEST_ASSERT_TRUE(is_isogram("isogram"));
}

static void test_word_with_one_duplicated_character(void)
{
   TEST_ASSERT_FALSE(is_isogram("eleven"));
}

static void test_word_with_one_duplicated_character_from_end_of_alphabet(void)
{
   TEST_ASSERT_FALSE(is_isogram("zzyzx"));
}

static void test_longest_reported_english_isogram(void)
{
   TEST_ASSERT_TRUE(is_isogram("subdermatoglyphic"));
}

static void test_word_with_duplicated_letter_in_mixed_case(void)
{
   TEST_ASSERT_FALSE(is_isogram("Alphabet"));
}

static void test_word_with_duplicated_letter_in_mixed_case_lowercase_first(void)
{
   TEST_ASSERT_FALSE(is_isogram("alphAbet"));
}

static void test_hypothetical_isogrammic_word_with_hyphen(void)
{
   TEST_ASSERT_TRUE(is_isogram("thumbscrew-japingly"));
}

static void
test_hypothetical_word_with_duplicated_character_following_hyphen(void)
{
   TEST_ASSERT_FALSE(is_isogram("thumbscrew-jappingly"));
}

static void test_isogram_with_duplicated_hyphen(void)
{
   TEST_ASSERT_TRUE(is_isogram("six-year-old"));
}

static void test_made_up_name_that_is_an_isogram(void)
{
   TEST_ASSERT_TRUE(is_isogram("Emily Jung Schwartzkopf"));
}

static void test_duplicated_character_in_the_middle(void)
{
   TEST_ASSERT_FALSE(is_isogram("accentor"));
}

static void test_same_first_and_last_characters(void)
{
   TEST_ASSERT_FALSE(is_isogram("angola"));
}

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

   RUN_TEST(test_empty_string);
   RUN_TEST(test_null);
   RUN_TEST(test_isogram_with_only_lower_case_characters);
   RUN_TEST(test_word_with_one_duplicated_character);
   RUN_TEST(test_word_with_one_duplicated_character_from_end_of_alphabet);
   RUN_TEST(test_longest_reported_english_isogram);
   RUN_TEST(test_word_with_duplicated_letter_in_mixed_case);
   RUN_TEST(test_word_with_duplicated_letter_in_mixed_case_lowercase_first);
   RUN_TEST(test_hypothetical_isogrammic_word_with_hyphen);
   RUN_TEST(test_hypothetical_word_with_duplicated_character_following_hyphen);
   RUN_TEST(test_isogram_with_duplicated_hyphen);
   RUN_TEST(test_made_up_name_that_is_an_isogram);
   RUN_TEST(test_duplicated_character_in_the_middle);
   RUN_TEST(test_same_first_and_last_characters);

   return UnityEnd();
}