26 #include "dbus-internals.h"
27 #include "dbus-string.h"
28 #define DBUS_CAN_USE_DBUS_STRING_PRIVATE 1
29 #include "dbus-string-private.h"
49 const unsigned char *ap;
50 const unsigned char *bp;
51 const unsigned char *a_end;
52 unsigned long c_str_len;
57 c_str_len = strlen (c_str);
58 if (((
unsigned long)real_a->
len) < c_str_len)
61 ap = real_a->
str + (real_a->
len - c_str_len);
62 bp = (
const unsigned char*) c_str;
63 a_end = real_a->
str + real_a->
len;
104 if (real->str[i] == byte)
118 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
119 #include "dbus-test.h"
123 test_hex_roundtrip (
const char *data,
158 printf (
"Original string %d bytes encoded %d bytes decoded %d bytes\n",
162 printf (
"Original: %s\n", data);
164 printf (
"Decoded: %s\n", s);
173 typedef void (* TestRoundtripFunc) (
const char *data,
176 test_roundtrips (TestRoundtripFunc func)
178 (* func) (
"Hello this is a string\n", -1);
179 (* func) (
"Hello this is a string\n1", -1);
180 (* func) (
"Hello this is a string\n12", -1);
181 (* func) (
"Hello this is a string\n123", -1);
182 (* func) (
"Hello this is a string\n1234", -1);
183 (* func) (
"Hello this is a string\n12345", -1);
188 (* func) (
"1234", 4);
189 (* func) (
"12345", 5);
194 (* func) (
"1234", 5);
195 (* func) (
"12345", 6);
197 unsigned char buf[512];
209 (* func) ((
const char *) buf, i);
226 _dbus_string_test (
void)
232 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 };
405 "Hello WorldHello World"));
413 "Hello WorldHello WorldHello World"));
446 "HelloHello WorldWorld"));
458 "HelloHello WorldWorle"));
491 "Foo Hello String"));
502 "Foo Hello String World"));
513 "Foo Hello String Hello"));
699 test_roundtrips (test_hex_roundtrip);
704 int found, found_len;
710 if (found != 3 || found_len != 2)
715 if (found != 8 || found_len != 1)
720 else if (found != 11 || found_len != 0)
751 #define FIRST_LINE "this is a line"
752 #define SECOND_LINE "this is a second line"
754 #define THIRD_LINE ""
755 #define FOURTH_LINE "this is a fourth line"
760 if (!
_dbus_string_append (&str, FIRST_LINE
"\n" SECOND_LINE
"\r\n" THIRD_LINE
"\n" FOURTH_LINE))
794 for (i = 0; i < 10000; i++)
847 const char two_strings[] =
"one\ttwo";
872 const char upper_string[] =
"TOUPPERSTRING";
873 const char lower_string[] =
"toupperstring";
874 const char lower2_string[] =
"toupperSTRING";
904 const char lower_string[] =
"toupperstring";
905 const char upper_string[] =
"TOUPPERSTRING";
906 const char upper2_string[] =
"TOUPPERstring";