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
|
#include <cgreen/cgreen.h>
#include "words.h"
#include <string.h>
Describe(Words);
BeforeEach(Words) {}
AfterEach(Words) {}
Ensure(Words, returns_word_count) {
char *sentence = strdup("Birds of a feather");
int word_count = split_words(sentence);
assert_that(word_count, is_equal_to(4));
free(sentence);
}
Ensure(Words, converts_spaces_to_zeroes) {
char *sentence = strdup("Birds of a feather");
split_words(sentence);
int comparison = memcmp("Birds\0of\0a\0feather", sentence, strlen(sentence));
assert_that(comparison, is_equal_to(0));
free(sentence);
}
TestSuite *words_tests() {
TestSuite *suite = create_test_suite();
add_test_with_context(suite, Words, returns_word_count);
add_test_with_context(suite, Words, converts_spaces_to_zeroes);
return suite;
}
|