Closed rafaeldelboni closed 3 years ago
Yes I was missing something haha
char* s1;
char* s2;
char* instruction = "RTS";
s1 = sc_str_create("");
s2 = sc_str_create("RTS ");
sc_str_append_fmt(&s1, "%s ", instruction);
assert(sc_str_cmp(s1,s2));
Doesn't it create "(null) RTS " ? In our codebase, for these kind of scenarios we use :
void test7()
{
char* s1;
char* instruction = "RTS";
s1 = sc_str_create(""); // Initial value
sc_str_append_fmt(&s1, "%s ", instruction);
assert(strcmp(s1,"RTS ") == 0); // equals zero
}
But I understand appending to null should create same string as if appending to empty string, at least it's the intuitive way I believe.
I'll think about that and check our usages, hopefully we can change this behaviour. Thanks a lot. :)
This is intended or is there something I'm missing?
Steps to reproduce:
Make a new test on
string/str_test.c
Error log: