treebird/test/unit/string_test.c
me@ow.nekobit.net 392ef8cb81 String replace
FossilOrigin-Name: 63773000f0554657fd047c0416a22def13bb02da3eb18bfb87fcd6ba60fa55ae
2022-04-19 03:24:41 +00:00

20 lines
625 B
C

#include <string.h>
#include "../../src/string.h"
int string_replace_test(void)
{
char* res1 = strrepl("hello world", "wo", "swi");
assert(strcmp(res1, "hello swirld") == 0);
char* res2 = strrepl("hello world itswo the world wo", "wo", "swi");
assert(strcmp(res2, "hello swirld itsswi the swirld swi") == 0);
char* res3 = strrepl(">implying\nhuh? <><", ">", "&gt;");
assert(strcmp(res3, "&gt;implying\nhuh? <&gt;<") == 0);
char* res4 = strrepl(">lol >hi", ">", ">>>");
assert(strcmp(res4, ">>>lol >>>hi") == 0);
free(res1);
free(res2);
free(res3);
free(res4);
return 0;
}