fix string unit tests after strcpy was removed

This commit is contained in:
Enno Rehling 2018-12-01 20:39:39 +01:00
parent d162c2dee1
commit 3f9331cd09
1 changed files with 12 additions and 0 deletions

View File

@ -151,14 +151,22 @@ static void test_sbstring(CuTest * tc)
CuAssertStrEquals(tc, "Hodor", sbs.begin); CuAssertStrEquals(tc, "Hodor", sbs.begin);
sbs_strcat(&sbs, "Hodor"); sbs_strcat(&sbs, "Hodor");
CuAssertStrEquals(tc, "HodorHodor", sbs.begin); CuAssertStrEquals(tc, "HodorHodor", sbs.begin);
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "Hodor"); sbs_strcat(&sbs, "Hodor");
CuAssertStrEquals(tc, "Hodor", sbs.begin); CuAssertStrEquals(tc, "Hodor", sbs.begin);
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678901234567890"); sbs_strcat(&sbs, "12345678901234567890");
CuAssertStrEquals(tc, "123456789012345", sbs.begin); CuAssertStrEquals(tc, "123456789012345", sbs.begin);
CuAssertPtrEquals(tc, sbs.begin + sbs.size - 1, sbs.end); CuAssertPtrEquals(tc, sbs.begin + sbs.size - 1, sbs.end);
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678901234567890"); sbs_strcat(&sbs, "12345678901234567890");
CuAssertStrEquals(tc, "123456789012345", sbs.begin); CuAssertStrEquals(tc, "123456789012345", sbs.begin);
CuAssertPtrEquals(tc, buffer, sbs.begin); CuAssertPtrEquals(tc, buffer, sbs.begin);
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "1234567890"); sbs_strcat(&sbs, "1234567890");
CuAssertStrEquals(tc, "1234567890", sbs.begin); CuAssertStrEquals(tc, "1234567890", sbs.begin);
sbs_strncat(&sbs, "1234567890", 4); sbs_strncat(&sbs, "1234567890", 4);
@ -208,24 +216,28 @@ static void test_sbs_substr(CuTest * tc)
CuAssertStrEquals(tc, "1234", buffer); CuAssertStrEquals(tc, "1234", buffer);
CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs)); CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs));
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678"); sbs_strcat(&sbs, "12345678");
CuAssertStrEquals(tc, "12345678", buffer); CuAssertStrEquals(tc, "12345678", buffer);
sbs_substr(&sbs, 4, 4); sbs_substr(&sbs, 4, 4);
CuAssertStrEquals(tc, "5678", buffer); CuAssertStrEquals(tc, "5678", buffer);
CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs)); CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs));
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678"); sbs_strcat(&sbs, "12345678");
CuAssertStrEquals(tc, "12345678", buffer); CuAssertStrEquals(tc, "12345678", buffer);
sbs_substr(&sbs, 2, 4); sbs_substr(&sbs, 2, 4);
CuAssertStrEquals(tc, "3456", buffer); CuAssertStrEquals(tc, "3456", buffer);
CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs)); CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs));
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678"); sbs_strcat(&sbs, "12345678");
CuAssertStrEquals(tc, "12345678", buffer); CuAssertStrEquals(tc, "12345678", buffer);
sbs_substr(&sbs, 4, 4); sbs_substr(&sbs, 4, 4);
CuAssertStrEquals(tc, "5678", buffer); CuAssertStrEquals(tc, "5678", buffer);
CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs)); CuAssertIntEquals(tc, 4, (int)sbs_length(&sbs));
sbs_init(&sbs, buffer, sizeof(buffer));
sbs_strcat(&sbs, "12345678"); sbs_strcat(&sbs, "12345678");
CuAssertStrEquals(tc, "12345678", buffer); CuAssertStrEquals(tc, "12345678", buffer);
sbs_substr(&sbs, 4, 8); sbs_substr(&sbs, 4, 8);