From: Simon McVittie Date: Mon, 6 Nov 2017 18:44:43 +0000 (+0000) Subject: tests: Assert that _DBUS_STRING_DEFINE_STATIC looks as expected X-Git-Tag: dbus-1.13.0~117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96d878d90c79bf2b28790243e23f3f666c241142;p=thirdparty%2Fdbus.git tests: Assert that _DBUS_STRING_DEFINE_STATIC looks as expected Signed-off-by: Simon McVittie Reviewed-by: Philip Withnall Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104 --- diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 85bc57056..d47ac751a 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -212,6 +212,8 @@ test_roundtrips (TestRoundtripFunc func) } } +_DBUS_STRING_DEFINE_STATIC (test_static_string, "hello"); + /** * @ingroup DBusStringInternals * Unit test for DBusString. @@ -231,6 +233,16 @@ _dbus_string_test (void) long v; int lens[] = { 0, 1, 2, 3, 4, 5, 10, 16, 17, 18, 25, 31, 32, 33, 34, 35, 63, 64, 65, 66, 67, 68, 69, 70, 71, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136 }; char *s; + DBusRealString *real_test_static_string = (DBusRealString *) &test_static_string; + + _dbus_assert (real_test_static_string->str != NULL); + _dbus_assert (strcmp ((const char *) real_test_static_string->str, "hello") == 0); + _dbus_assert (real_test_static_string->len == 5); + _dbus_assert (real_test_static_string->allocated > 5); + _dbus_assert (real_test_static_string->constant); + _dbus_assert (real_test_static_string->locked); + _dbus_assert (!real_test_static_string->invalid); + _dbus_assert (real_test_static_string->align_offset == 0); /* Test shortening and setting length */ i = 0;