diff options
author | James Booth <boothj5@gmail.com> | 2012-04-19 22:26:12 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-04-19 22:26:12 +0100 |
commit | 366eecc19569f14a6081e1acb6efd72a372982da (patch) | |
tree | 7778440a1210f49a21b10a10e142030a17cb1f30 /test_util.c | |
parent | 9805b2b2b22e277ee150ddaabe8f542b267e3e4b (diff) | |
download | profani-tty-366eecc19569f14a6081e1acb6efd72a372982da.tar.gz |
Handle ampersand
Replaced with & in messages
Diffstat (limited to 'test_util.c')
-rw-r--r-- | test_util.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test_util.c b/test_util.c new file mode 100644 index 00000000..e2327be5 --- /dev/null +++ b/test_util.c @@ -0,0 +1,68 @@ +#include <stdlib.h> +#include <head-unit.h> +#include "util.h" + +void replace_one_substr(void) +{ + char *string = "it is a string"; + char *sub = "is"; + char *new = "was"; + + char *result = str_replace(string, sub, new); + + assert_string_equals("it was a string", result); +} + +void replace_one_substr_beginning(void) +{ + char *string = "it is a string"; + char *sub = "it"; + char *new = "that"; + + char *result = str_replace(string, sub, new); + + assert_string_equals("that is a string", result); +} + +void replace_one_substr_end(void) +{ + char *string = "it is a string"; + char *sub = "string"; + char *new = "thing"; + + char *result = str_replace(string, sub, new); + + assert_string_equals("it is a thing", result); +} + +void replace_two_substr(void) +{ + char *string = "it is a is string"; + char *sub = "is"; + char *new = "was"; + + char *result = str_replace(string, sub, new); + + assert_string_equals("it was a was string", result); +} + +void replace_char(void) +{ + char *string = "some & a thing & something else"; + char *sub = "&"; + char *new = "&"; + + char *result = str_replace(string, sub, new); + + assert_string_equals("some & a thing & something else", result); +} + +void register_util_tests(void) +{ + TEST_MODULE("util tests"); + TEST(replace_one_substr); + TEST(replace_one_substr_beginning); + TEST(replace_one_substr_end); + TEST(replace_two_substr); + TEST(replace_char); +} |