]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Assert that _DBUS_STRING_DEFINE_STATIC looks as expected
authorSimon McVittie <smcv@collabora.com>
Mon, 6 Nov 2017 18:44:43 +0000 (18:44 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 7 Nov 2017 11:38:17 +0000 (11:38 +0000)
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104

dbus/dbus-string-util.c

index 85bc57056293ba3a99020aa56f93731b5503b0d1..d47ac751a069885f7e4d94fcc974d48143abaac4 100644 (file)
@@ -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;