core: add stringstream indent unit test
This commit is contained in:
@@ -169,6 +169,26 @@ void test_stringstream_1(CuTest *tc)
|
||||
CuAssertStrEquals(tc, "hello(32 + 2.3)ABCDEFABCDEFmoremoremore", end);
|
||||
}
|
||||
|
||||
void test_stringstream_2(CuTest *tc)
|
||||
{
|
||||
char buf[1024];
|
||||
b_stringstream s;
|
||||
b_stringstream_begin(&s, buf, sizeof buf);
|
||||
|
||||
b_stringstream_add(&s, "{\n");
|
||||
b_stringstream_push_indent(&s, 1);
|
||||
|
||||
b_stringstream_add(&s, "a = 32,\n");
|
||||
b_stringstream_add(&s, "b = 64\n");
|
||||
|
||||
b_stringstream_pop_indent(&s);
|
||||
b_stringstream_add(&s, "}");
|
||||
|
||||
char *str = b_stringstream_end(&s);
|
||||
|
||||
CuAssertStrEquals(tc, "{\n a = 32,\n b = 64\n}", str);
|
||||
}
|
||||
|
||||
CuSuite *get_all_tests(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
@@ -178,6 +198,7 @@ CuSuite *get_all_tests(void)
|
||||
SUITE_ADD_TEST(suite, test_queue_insert);
|
||||
SUITE_ADD_TEST(suite, test_queue_iterate);
|
||||
SUITE_ADD_TEST(suite, test_stringstream_1);
|
||||
SUITE_ADD_TEST(suite, test_stringstream_2);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user