2018-06-11 06:26:57 +00:00
|
|
|
void DqnFixedString_Test()
|
|
|
|
{
|
|
|
|
LOG_HEADER();
|
|
|
|
{
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello world") == 0);
|
|
|
|
|
|
|
|
Log(Status::Ok, "Copy constructor DqnSlice<char>");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
DqnFixedString<512> zero = {};
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
str = zero;
|
|
|
|
DQN_ASSERT(str.len == 0 && str.str[0] == 0);
|
|
|
|
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnSlice<char const> helloSlice = DQN_SLICE("hello");
|
2018-06-11 06:26:57 +00:00
|
|
|
str = helloSlice;
|
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello") == 0);
|
|
|
|
|
|
|
|
Log(Status::Ok, "Copy constructor (DqnFixedString<>)");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor") == 0);
|
|
|
|
|
|
|
|
Log(Status::Ok, "Sprintf");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
2018-06-25 10:54:38 +00:00
|
|
|
str += DQN_SLICE(".end");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor.end") == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
|
|
|
DQN_ASSERT(str.SprintfAppend(" %d, %d", 100, 200));
|
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor 100, 200") == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Log(Status::Ok, "Concatenation, operator +=, SprintfAppend");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
DqnFixedString<512> str;
|
|
|
|
str = "hello big world";
|
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello big world") == 0);
|
|
|
|
str = DqnFixedString<512>("goodbye", DQN_CHAR_COUNT("goodbye"));
|
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "goodbye") == 0);
|
|
|
|
|
|
|
|
Log(Status::Ok, "Copy constructor (char const *str, int len)");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2018-06-25 10:54:38 +00:00
|
|
|
DqnFixedString<512> str = DQN_SLICE("hello world");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
2018-06-25 10:54:38 +00:00
|
|
|
str = str + " end" + DQN_SLICE(" of");
|
2018-06-11 06:26:57 +00:00
|
|
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor end of") == 0);
|
|
|
|
|
|
|
|
Log(Status::Ok, "Operator +");
|
|
|
|
}
|
|
|
|
}
|