mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 07:26:21 +00:00
Handle ampersand
Replaced with & in messages
This commit is contained in:
68
test_util.c
Normal file
68
test_util.c
Normal file
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user