Debian Codegraph @

doc/tutorial_src/words_tests2.c

raw symbols SCIP
1 #include <cgreen/cgreen.h>
2
3 #include "words.h"
4 #include <string.h>
5
6 Describe(Words);
7 BeforeEach(Words) {}
8 AfterEach(Words) {}
9
10 Ensure(Words, returns_word_count) {
11 char *sentence = strdup("Birds of a feather");
12 int word_count = split_words(sentence);
13 assert_that(word_count, is_equal_to(4));
14 free(sentence);
15 }
16
17 Ensure(Words, converts_spaces_to_zeroes) {
18 char *sentence = strdup("Birds of a feather");
19 split_words(sentence);
20 int comparison = memcmp("Birds\0of\0a\0feather", sentence, strlen(sentence));
21 assert_that(comparison, is_equal_to(0));
22 free(sentence);
23 }
24
25 TestSuite *words_tests() {
26 TestSuite *suite = create_test_suite();
27 add_test_with_context(suite, Words, returns_word_count);
28 add_test_with_context(suite, Words, converts_spaces_to_zeroes);
29 return suite;
30 }