[daemon-fix] fixed querying about name information
[platform/upstream/dbus.git] / dbus / dbus-string-util.c
index b31703c..3babc05 100644 (file)
@@ -115,31 +115,11 @@ _dbus_string_find_byte_backward (const DBusString  *str,
 
 /** @} */
 
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
 #include "dbus-test.h"
 #include <stdio.h>
 
 static void
-test_max_len (DBusString *str,
-              int         max_len)
-{
-  if (max_len > 0)
-    {
-      if (!_dbus_string_set_length (str, max_len - 1))
-        _dbus_assert_not_reached ("setting len to one less than max should have worked");
-    }
-
-  if (!_dbus_string_set_length (str, max_len))
-    _dbus_assert_not_reached ("setting len to max len should have worked");
-
-  if (_dbus_string_set_length (str, max_len + 1))
-    _dbus_assert_not_reached ("setting len to one more than max len should not have worked");
-
-  if (!_dbus_string_set_length (str, 0))
-    _dbus_assert_not_reached ("setting len to zero should have worked");
-}
-
-static void
 test_hex_roundtrip (const unsigned char *data,
                     int                  len)
 {
@@ -232,25 +212,6 @@ test_roundtrips (TestRoundtripFunc func)
   }
 }
 
-#ifdef DBUS_BUILD_TESTS
-/* The max length thing is sort of a historical artifact
- * from a feature that turned out to be dumb; perhaps
- * we should purge it entirely. The problem with
- * the feature is that it looks like memory allocation
- * failure, but is not a transient or resolvable failure.
- */
-static void
-set_max_length (DBusString *str,
-                int         max_length)
-{
-  DBusRealString *real;
-  
-  real = (DBusRealString*) str;
-
-  real->max_length = max_length;
-}
-#endif /* DBUS_BUILD_TESTS */
-
 /**
  * @ingroup DBusStringInternals
  * Unit test for DBusString.
@@ -268,24 +229,8 @@ _dbus_string_test (void)
   DBusString other;
   int i, a, end;
   long v;
-  double d;
   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;
-  dbus_unichar_t ch;
-  
-  i = 0;
-  while (i < _DBUS_N_ELEMENTS (lens))
-    {
-      if (!_dbus_string_init (&str))
-        _dbus_assert_not_reached ("failed to init string");
-
-      set_max_length (&str, lens[i]);
-      
-      test_max_len (&str, lens[i]);
-      _dbus_string_free (&str);
-
-      ++i;
-    }
 
   /* Test shortening and setting length */
   i = 0;
@@ -296,8 +241,6 @@ _dbus_string_test (void)
       if (!_dbus_string_init (&str))
         _dbus_assert_not_reached ("failed to init string");
 
-      set_max_length (&str, lens[i]);
-      
       if (!_dbus_string_set_length (&str, lens[i]))
         _dbus_assert_not_reached ("failed to set string length");
 
@@ -601,22 +544,6 @@ _dbus_string_test (void)
   _dbus_string_free (&str);
   _dbus_string_free (&other);
 
-  /* Check append/get unichar */
-  
-  if (!_dbus_string_init (&str))
-    _dbus_assert_not_reached ("failed to init string");
-
-  ch = 0;
-  if (!_dbus_string_append_unichar (&str, 0xfffc))
-    _dbus_assert_not_reached ("failed to append unichar");
-
-  _dbus_string_get_unichar (&str, 0, &ch, &i);
-
-  _dbus_assert (ch == 0xfffc);
-  _dbus_assert (i == _dbus_string_get_length (&str));
-
-  _dbus_string_free (&str);
-
   /* Check insert/set/get byte */
   
   if (!_dbus_string_init (&str))
@@ -674,22 +601,6 @@ _dbus_string_test (void)
   _dbus_assert (end == i);
 
   _dbus_string_free (&str);
-  
-  if (!_dbus_string_init (&str))
-    _dbus_assert_not_reached ("failed to init string");
-  
-  if (!_dbus_string_append_double (&str, 50.3))
-    _dbus_assert_not_reached ("failed to append float");
-
-  i = _dbus_string_get_length (&str);
-
-  if (!_dbus_string_parse_double (&str, 0, &d, &end))
-    _dbus_assert_not_reached ("failed to parse float");
-
-  _dbus_assert (d > (50.3 - 1e-6) && d < (50.3 + 1e-6));
-  _dbus_assert (end == i);
-
-  _dbus_string_free (&str);
 
   /* Test find */
   if (!_dbus_string_init (&str))
@@ -1024,4 +935,4 @@ _dbus_string_test (void)
   return TRUE;
 }
 
-#endif /* DBUS_BUILD_TESTS */
+#endif /* DBUS_ENABLE_EMBEDDED_TESTS */