Commit aa270e7b authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Run getter tests on empty buffers

parent bc697194
...@@ -94,6 +94,50 @@ static void test_associated(void) ...@@ -94,6 +94,50 @@ static void test_associated(void)
ctest_test("un-referenced (2 of 2)", refobject_unref(a) == 0); ctest_test("un-referenced (2 of 2)", refobject_unref(a) == 0);
} }
static void test_empty(void)
{
buffer_t *a;
const void *data = &data;
size_t length = 5;
const char *string;
int ret;
a = buffer_new_simple();
ctest_test("buffer created", a != NULL);
ret = buffer_get_data(a, &data, &length);
ctest_test("got data and length from buffer", ret == 0);
if (ret == 0) {
ctest_test("data is updated", data != &data);
ctest_test("length is zero", length == 0);
}
data = &data;
ret = buffer_get_data(a, &data, NULL);
ctest_test("got data from buffer", ret == 0);
if (ret == 0) {
ctest_test("data is updated", data != &data);
}
length = 5;
ret = buffer_get_data(a, NULL, &length);
ctest_test("got length from buffer", ret == 0);
if (ret == 0) {
ctest_test("length is zero", length == 0);
}
ret = buffer_get_string(a, &string);
ctest_test("got string from buffer", ret == 0);
if (ret == 0) {
ctest_test("string is non-NULL", string != NULL);
if (string != NULL) {
ctest_test("string is empty", *string == 0);
}
}
ctest_test("un-referenced", refobject_unref(a) == 0);
}
int main (void) int main (void)
{ {
ctest_init(); ctest_init();
...@@ -105,6 +149,8 @@ int main (void) ...@@ -105,6 +149,8 @@ int main (void)
test_userdata(); test_userdata();
test_associated(); test_associated();
test_empty();
ctest_fin(); ctest_fin();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment