diff options
Diffstat (limited to 'linden/indra/test/llstring_tut.cpp')
-rw-r--r-- | linden/indra/test/llstring_tut.cpp | 498 |
1 files changed, 498 insertions, 0 deletions
diff --git a/linden/indra/test/llstring_tut.cpp b/linden/indra/test/llstring_tut.cpp new file mode 100644 index 0000000..040955b --- /dev/null +++ b/linden/indra/test/llstring_tut.cpp | |||
@@ -0,0 +1,498 @@ | |||
1 | /** | ||
2 | * @file llstring_tut.cpp | ||
3 | * @author Adroit | ||
4 | * @date 2006-12-24 | ||
5 | * @brief Test cases of llstring.cpp | ||
6 | * | ||
7 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
8 | * | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlife.com/developers/opensource/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | */ | ||
29 | |||
30 | #include <tut/tut.h> | ||
31 | #include "lltut.h" | ||
32 | #include "linden_common.h" | ||
33 | #include "llstring.h" | ||
34 | |||
35 | namespace tut | ||
36 | { | ||
37 | struct string_index | ||
38 | { | ||
39 | }; | ||
40 | typedef test_group<string_index> string_index_t; | ||
41 | typedef string_index_t::object string_index_object_t; | ||
42 | tut::string_index_t tut_string_index("string_test"); | ||
43 | |||
44 | template<> template<> | ||
45 | void string_index_object_t::test<1>() | ||
46 | { | ||
47 | LLString llstr1; | ||
48 | ensure("Empty LLString", (llstr1.size() == 0) && llstr1.empty()); | ||
49 | |||
50 | LLString llstr2("Hello"); | ||
51 | ensure("LLString = Hello", (!strcmp(llstr2.c_str(), "Hello")) && (llstr2.size() == 5) && !llstr2.empty()); | ||
52 | |||
53 | LLString llstr3(llstr2); | ||
54 | ensure("LLString = LLString(LLString)", (!strcmp(llstr3.c_str(), "Hello")) && (llstr3.size() == 5) && !llstr3.empty()); | ||
55 | |||
56 | std::string str("Hello World"); | ||
57 | LLString llstr4(str, 6); | ||
58 | ensure("LLString = LLString(s, size_type pos, size_type n = npos)", (!strcmp(llstr4.c_str(), "World")) && (llstr4.size() == 5) && !llstr4.empty()); | ||
59 | |||
60 | LLString llstr5(str, str.size()); | ||
61 | ensure("LLString = LLString(s, size_type pos, size_type n = npos)", (llstr5.size() == 0) && llstr5.empty()); | ||
62 | |||
63 | LLString llstr6(5, 'A'); | ||
64 | ensure("LLString = LLString(count, c)", (!strcmp(llstr6.c_str(), "AAAAA")) && (llstr6.size() == 5) && !llstr6.empty()); | ||
65 | |||
66 | LLString llstr7("Hello World", 5); | ||
67 | ensure("LLString(s, n)", (!strcmp(llstr7.c_str(), "Hello")) && (llstr7.size() == 5) && !llstr7.empty()); | ||
68 | |||
69 | LLString llstr8("Hello World", 6, 5); | ||
70 | ensure("LLString(s, n, count)", (!strcmp(llstr8.c_str(), "World")) && (llstr8.size() == 5) && !llstr8.empty()); | ||
71 | |||
72 | LLString llstr9("Hello World", sizeof("Hello World")-1, 5); // go past end | ||
73 | ensure("LLString(s, n, count) goes past end", (llstr9.size() == 0) && llstr9.empty()); | ||
74 | } | ||
75 | |||
76 | template<> template<> | ||
77 | void string_index_object_t::test<2>() | ||
78 | { | ||
79 | LLString str("Len=5"); | ||
80 | ensure("isValidIndex failed", LLString::isValidIndex(str, 0) == TRUE && | ||
81 | LLString::isValidIndex(str, 5) == TRUE && | ||
82 | LLString::isValidIndex(str, 6) == FALSE); | ||
83 | |||
84 | LLString str1; | ||
85 | ensure("isValidIndex failed fo rempty string", LLString::isValidIndex(str1, 0) == FALSE); | ||
86 | } | ||
87 | |||
88 | template<> template<> | ||
89 | void string_index_object_t::test<3>() | ||
90 | { | ||
91 | LLString str_val(" Testing the extra whitespaces "); | ||
92 | LLString::trimHead(str_val); | ||
93 | ensure_equals("1: trimHead failed", str_val, "Testing the extra whitespaces "); | ||
94 | |||
95 | LLString str_val1("\n\t\r\n Testing the extra whitespaces "); | ||
96 | LLString::trimHead(str_val1); | ||
97 | ensure_equals("2: trimHead failed", str_val1, "Testing the extra whitespaces "); | ||
98 | } | ||
99 | |||
100 | template<> template<> | ||
101 | void string_index_object_t::test<4>() | ||
102 | { | ||
103 | LLString str_val(" Testing the extra whitespaces "); | ||
104 | LLString::trimTail(str_val); | ||
105 | ensure_equals("1: trimTail failed", str_val, " Testing the extra whitespaces"); | ||
106 | |||
107 | LLString str_val1("\n Testing the extra whitespaces \n\t\r\n "); | ||
108 | LLString::trimTail(str_val1); | ||
109 | ensure_equals("2: trimTail failed", str_val1, "\n Testing the extra whitespaces"); | ||
110 | } | ||
111 | |||
112 | |||
113 | template<> template<> | ||
114 | void string_index_object_t::test<5>() | ||
115 | { | ||
116 | LLString str_val(" \t \r Testing the extra \r\n whitespaces \n \t "); | ||
117 | LLString::trim(str_val); | ||
118 | ensure_equals("1: trim failed", str_val, "Testing the extra \r\n whitespaces"); | ||
119 | } | ||
120 | |||
121 | template<> template<> | ||
122 | void string_index_object_t::test<6>() | ||
123 | { | ||
124 | LLString str("Second LindenLabs"); | ||
125 | LLString::truncate(str, 6); | ||
126 | ensure_equals("1: truncate", str, "Second"); | ||
127 | |||
128 | // further truncate more than the length | ||
129 | LLString::truncate(str, 0); | ||
130 | ensure_equals("2: truncate", str, ""); | ||
131 | } | ||
132 | |||
133 | template<> template<> | ||
134 | void string_index_object_t::test<7>() | ||
135 | { | ||
136 | LLString str_val("SecondLife Source"); | ||
137 | LLString::toUpper(str_val); | ||
138 | ensure_equals("toUpper failed", str_val, "SECONDLIFE SOURCE"); | ||
139 | } | ||
140 | |||
141 | template<> template<> | ||
142 | void string_index_object_t::test<8>() | ||
143 | { | ||
144 | LLString str_val("SecondLife Source"); | ||
145 | LLString::toLower(str_val); | ||
146 | ensure_equals("toLower failed", str_val, "secondlife source"); | ||
147 | } | ||
148 | |||
149 | template<> template<> | ||
150 | void string_index_object_t::test<9>() | ||
151 | { | ||
152 | LLString str_val("Second"); | ||
153 | ensure("1. isHead failed", LLString::isHead(str_val, "SecondLife Source") == TRUE); | ||
154 | ensure("2. isHead failed", LLString::isHead(str_val, " SecondLife Source") == FALSE); | ||
155 | LLString str_val2(""); | ||
156 | ensure("3. isHead failed", LLString::isHead(str_val2, "") == FALSE); | ||
157 | } | ||
158 | |||
159 | template<> template<> | ||
160 | void string_index_object_t::test<10>() | ||
161 | { | ||
162 | LLString str_val("Hello.\n\n Lindenlabs. \n This is \na simple test.\n"); | ||
163 | LLString orig_str_val(str_val); | ||
164 | LLString::addCRLF(str_val); | ||
165 | ensure_equals("addCRLF failed", str_val, "Hello.\r\n\r\n Lindenlabs. \r\n This is \r\na simple test.\r\n"); | ||
166 | LLString::removeCRLF(str_val); | ||
167 | ensure_equals("removeCRLF failed", str_val, orig_str_val); | ||
168 | } | ||
169 | |||
170 | template<> template<> | ||
171 | void string_index_object_t::test<11>() | ||
172 | { | ||
173 | LLString str_val("Hello.\n\n\t \t Lindenlabs. \t\t"); | ||
174 | LLString orig_str_val(str_val); | ||
175 | LLString::replaceTabsWithSpaces(str_val, 1); | ||
176 | ensure_equals("replaceTabsWithSpaces failed", str_val, "Hello.\n\n Lindenlabs. "); | ||
177 | LLString::replaceTabsWithSpaces(orig_str_val, 0); | ||
178 | ensure_equals("replaceTabsWithSpaces failed for 0", orig_str_val, "Hello.\n\n Lindenlabs. "); | ||
179 | |||
180 | str_val = "\t\t\t\t"; | ||
181 | LLString::replaceTabsWithSpaces(str_val, 0); | ||
182 | ensure_equals("replaceTabsWithSpaces failed for all tabs", str_val, ""); | ||
183 | } | ||
184 | |||
185 | template<> template<> | ||
186 | void string_index_object_t::test<12>() | ||
187 | { | ||
188 | LLString str_val("Hello.\n\n\t\t\r\nLindenlabsX."); | ||
189 | LLString::replaceNonstandardASCII(str_val, 'X'); | ||
190 | ensure_equals("replaceNonstandardASCII failed", str_val, "Hello.\n\nXXX\nLindenlabsX."); | ||
191 | } | ||
192 | |||
193 | template<> template<> | ||
194 | void string_index_object_t::test<13>() | ||
195 | { | ||
196 | LLString str_val("Hello.\n\t\r\nABCDEFGHIABABAB"); | ||
197 | LLString::replaceChar(str_val, 'A', 'X'); | ||
198 | ensure_equals("1: replaceChar failed", str_val, "Hello.\n\t\r\nXBCDEFGHIXBXBXB"); | ||
199 | LLString str_val1("Hello.\n\t\r\nABCDEFGHIABABAB"); | ||
200 | } | ||
201 | |||
202 | template<> template<> | ||
203 | void string_index_object_t::test<14>() | ||
204 | { | ||
205 | LLString str_val("Hello.\n\r\t"); | ||
206 | ensure("containsNonprintable failed", LLString::containsNonprintable(str_val) == TRUE); | ||
207 | |||
208 | str_val = "ABC "; | ||
209 | ensure("containsNonprintable failed", LLString::containsNonprintable(str_val) == FALSE); | ||
210 | } | ||
211 | |||
212 | template<> template<> | ||
213 | void string_index_object_t::test<15>() | ||
214 | { | ||
215 | LLString str_val("Hello.\n\r\t Again!"); | ||
216 | LLString::stripNonprintable(str_val); | ||
217 | ensure_equals("stripNonprintable failed", str_val, "Hello. Again!"); | ||
218 | |||
219 | str_val = "\r\n\t\t"; | ||
220 | LLString::stripNonprintable(str_val); | ||
221 | ensure_equals("stripNonprintable resulting in empty string failed", str_val, ""); | ||
222 | } | ||
223 | |||
224 | template<> template<> | ||
225 | void string_index_object_t::test<16>() | ||
226 | { | ||
227 | BOOL value; | ||
228 | LLString str_val("1"); | ||
229 | ensure("convertToBOOL 1 failed", LLString::convertToBOOL(str_val, value) && value); | ||
230 | str_val = "T"; | ||
231 | ensure("convertToBOOL T failed", LLString::convertToBOOL(str_val, value) && value); | ||
232 | str_val = "t"; | ||
233 | ensure("convertToBOOL t failed", LLString::convertToBOOL(str_val, value) && value); | ||
234 | str_val = "TRUE"; | ||
235 | ensure("convertToBOOL TRUE failed", LLString::convertToBOOL(str_val, value) && value); | ||
236 | str_val = "True"; | ||
237 | ensure("convertToBOOL True failed", LLString::convertToBOOL(str_val, value) && value); | ||
238 | str_val = "true"; | ||
239 | ensure("convertToBOOL true failed", LLString::convertToBOOL(str_val, value) && value); | ||
240 | |||
241 | str_val = "0"; | ||
242 | ensure("convertToBOOL 0 failed", LLString::convertToBOOL(str_val, value) && !value); | ||
243 | str_val = "F"; | ||
244 | ensure("convertToBOOL F failed", LLString::convertToBOOL(str_val, value) && !value); | ||
245 | str_val = "f"; | ||
246 | ensure("convertToBOOL f failed", LLString::convertToBOOL(str_val, value) && !value); | ||
247 | str_val = "FALSE"; | ||
248 | ensure("convertToBOOL FASLE failed", LLString::convertToBOOL(str_val, value) && !value); | ||
249 | str_val = "False"; | ||
250 | ensure("convertToBOOL False failed", LLString::convertToBOOL(str_val, value) && !value); | ||
251 | str_val = "false"; | ||
252 | ensure("convertToBOOL false failed", LLString::convertToBOOL(str_val, value) && !value); | ||
253 | |||
254 | str_val = "Tblah"; | ||
255 | ensure("convertToBOOL false failed", !LLString::convertToBOOL(str_val, value)); | ||
256 | } | ||
257 | |||
258 | template<> template<> | ||
259 | void string_index_object_t::test<17>() | ||
260 | { | ||
261 | U8 value; | ||
262 | LLString str_val("255"); | ||
263 | ensure("1: convertToU8 failed", LLString::convertToU8(str_val, value) && value == 255); | ||
264 | |||
265 | str_val = "0"; | ||
266 | ensure("2: convertToU8 failed", LLString::convertToU8(str_val, value) && value == 0); | ||
267 | |||
268 | str_val = "-1"; | ||
269 | ensure("3: convertToU8 failed", !LLString::convertToU8(str_val, value)); | ||
270 | |||
271 | str_val = "256"; // bigger than MAX_U8 | ||
272 | ensure("4: convertToU8 failed", !LLString::convertToU8(str_val, value)); | ||
273 | } | ||
274 | |||
275 | template<> template<> | ||
276 | void string_index_object_t::test<18>() | ||
277 | { | ||
278 | S8 value; | ||
279 | LLString str_val("127"); | ||
280 | ensure("1: convertToS8 failed", LLString::convertToS8(str_val, value) && value == 127); | ||
281 | |||
282 | str_val = "0"; | ||
283 | ensure("2: convertToS8 failed", LLString::convertToS8(str_val, value) && value == 0); | ||
284 | |||
285 | str_val = "-128"; | ||
286 | ensure("3: convertToS8 failed", LLString::convertToS8(str_val, value) && value == -128); | ||
287 | |||
288 | str_val = "128"; // bigger than MAX_S8 | ||
289 | ensure("4: convertToS8 failed", !LLString::convertToS8(str_val, value)); | ||
290 | |||
291 | str_val = "-129"; | ||
292 | ensure("5: convertToS8 failed", !LLString::convertToS8(str_val, value)); | ||
293 | } | ||
294 | |||
295 | template<> template<> | ||
296 | void string_index_object_t::test<19>() | ||
297 | { | ||
298 | S16 value; | ||
299 | LLString str_val("32767"); | ||
300 | ensure("1: convertToS16 failed", LLString::convertToS16(str_val, value) && value == 32767); | ||
301 | |||
302 | str_val = "0"; | ||
303 | ensure("2: convertToS16 failed", LLString::convertToS16(str_val, value) && value == 0); | ||
304 | |||
305 | str_val = "-32768"; | ||
306 | ensure("3: convertToS16 failed", LLString::convertToS16(str_val, value) && value == -32768); | ||
307 | |||
308 | str_val = "32768"; | ||
309 | ensure("4: convertToS16 failed", !LLString::convertToS16(str_val, value)); | ||
310 | |||
311 | str_val = "-32769"; | ||
312 | ensure("5: convertToS16 failed", !LLString::convertToS16(str_val, value)); | ||
313 | } | ||
314 | |||
315 | template<> template<> | ||
316 | void string_index_object_t::test<20>() | ||
317 | { | ||
318 | U16 value; | ||
319 | LLString str_val("65535"); //0xFFFF | ||
320 | ensure("1: convertToU16 failed", LLString::convertToU16(str_val, value) && value == 65535); | ||
321 | |||
322 | str_val = "0"; | ||
323 | ensure("2: convertToU16 failed", LLString::convertToU16(str_val, value) && value == 0); | ||
324 | |||
325 | str_val = "-1"; | ||
326 | ensure("3: convertToU16 failed", !LLString::convertToU16(str_val, value)); | ||
327 | |||
328 | str_val = "65536"; | ||
329 | ensure("4: convertToU16 failed", !LLString::convertToU16(str_val, value)); | ||
330 | } | ||
331 | |||
332 | template<> template<> | ||
333 | void string_index_object_t::test<21>() | ||
334 | { | ||
335 | U32 value; | ||
336 | LLString str_val("4294967295"); //0xFFFFFFFF | ||
337 | ensure("1: convertToU32 failed", LLString::convertToU32(str_val, value) && value == 4294967295); | ||
338 | |||
339 | str_val = "0"; | ||
340 | ensure("2: convertToU32 failed", LLString::convertToU32(str_val, value) && value == 0); | ||
341 | |||
342 | str_val = "-1"; | ||
343 | ensure("3: convertToU32 failed", LLString::convertToU32(str_val, value) && value == 4294967295); | ||
344 | |||
345 | str_val = "4294967296"; | ||
346 | ensure("4: convertToU32 failed", !LLString::convertToU32(str_val, value)); | ||
347 | } | ||
348 | |||
349 | template<> template<> | ||
350 | void string_index_object_t::test<22>() | ||
351 | { | ||
352 | S32 value; | ||
353 | LLString str_val("2147483647"); //0x7FFFFFFF | ||
354 | ensure("1: convertToS32 failed", LLString::convertToS32(str_val, value) && value == 2147483647); | ||
355 | |||
356 | str_val = "0"; | ||
357 | ensure("2: convertToS32 failed", LLString::convertToS32(str_val, value) && value == 0); | ||
358 | |||
359 | str_val = "-2147483648"; | ||
360 | ensure("3: convertToS32 failed", LLString::convertToS32(str_val, value) && value == -2147483648); | ||
361 | |||
362 | str_val = "2147483648"; | ||
363 | ensure("4: convertToS32 failed", !LLString::convertToS32(str_val, value)); | ||
364 | |||
365 | str_val = "-2147483649"; | ||
366 | ensure("5: convertToS32 failed", !LLString::convertToS32(str_val, value)); | ||
367 | } | ||
368 | |||
369 | template<> template<> | ||
370 | void string_index_object_t::test<23>() | ||
371 | { | ||
372 | F32 value; | ||
373 | LLString str_val("2147483647"); //0x7FFFFFFF | ||
374 | ensure("1: convertToF32 failed", LLString::convertToF32(str_val, value) && value == 2147483647); | ||
375 | |||
376 | str_val = "0"; | ||
377 | ensure("2: convertToF32 failed", LLString::convertToF32(str_val, value) && value == 0); | ||
378 | |||
379 | /* Need to find max/min F32 values | ||
380 | str_val = "-2147483648"; | ||
381 | ensure("3: convertToF32 failed", LLString::convertToF32(str_val, value) && value == -2147483648); | ||
382 | |||
383 | str_val = "2147483648"; | ||
384 | ensure("4: convertToF32 failed", !LLString::convertToF32(str_val, value)); | ||
385 | |||
386 | str_val = "-2147483649"; | ||
387 | ensure("5: convertToF32 failed", !LLString::convertToF32(str_val, value)); | ||
388 | */ | ||
389 | } | ||
390 | |||
391 | template<> template<> | ||
392 | void string_index_object_t::test<24>() | ||
393 | { | ||
394 | F64 value; | ||
395 | LLString str_val("9223372036854775807"); //0x7FFFFFFFFFFFFFFF | ||
396 | ensure("1: convertToF64 failed", LLString::convertToF64(str_val, value) && value == 9223372036854775807); | ||
397 | |||
398 | str_val = "0"; | ||
399 | ensure("2: convertToF64 failed", LLString::convertToF64(str_val, value) && value == 0); | ||
400 | |||
401 | /* Need to find max/min F64 values | ||
402 | str_val = "-2147483648"; | ||
403 | ensure("3: convertToF32 failed", LLString::convertToF32(str_val, value) && value == -2147483648); | ||
404 | |||
405 | str_val = "2147483648"; | ||
406 | ensure("4: convertToF32 failed", !LLString::convertToF32(str_val, value)); | ||
407 | |||
408 | str_val = "-2147483649"; | ||
409 | ensure("5: convertToF32 failed", !LLString::convertToF32(str_val, value)); | ||
410 | */ | ||
411 | } | ||
412 | |||
413 | template<> template<> | ||
414 | void string_index_object_t::test<25>() | ||
415 | { | ||
416 | char* str1 = NULL; | ||
417 | char* str2 = NULL; | ||
418 | |||
419 | ensure("1: compareStrings failed", LLString::compareStrings(str1, str2) == 0); | ||
420 | str2 = "A"; | ||
421 | ensure("2: compareStrings failed", LLString::compareStrings(str1, str2) > 0); | ||
422 | ensure("3: compareStrings failed", LLString::compareStrings(str2, str1) < 0); | ||
423 | |||
424 | str1 = "A is smaller than B"; | ||
425 | str2 = "B is greater than A"; | ||
426 | ensure("4: compareStrings failed", LLString::compareStrings(str1, str2) < 0); | ||
427 | |||
428 | str2 = "A is smaller than B"; | ||
429 | ensure("5: compareStrings failed", LLString::compareStrings(str1, str2) == 0); | ||
430 | } | ||
431 | |||
432 | template<> template<> | ||
433 | void string_index_object_t::test<26>() | ||
434 | { | ||
435 | char* str1 = NULL; | ||
436 | char* str2 = NULL; | ||
437 | |||
438 | ensure("1: compareInsensitive failed", LLString::compareInsensitive(str1, str2) == 0); | ||
439 | str2 = "A"; | ||
440 | ensure("2: compareInsensitive failed", LLString::compareInsensitive(str1, str2) > 0); | ||
441 | ensure("3: compareInsensitive failed", LLString::compareInsensitive(str2, str1) < 0); | ||
442 | |||
443 | str1 = "A is equal to a"; | ||
444 | str2 = "a is EQUAL to A"; | ||
445 | ensure("4: compareInsensitive failed", LLString::compareInsensitive(str1, str2) == 0); | ||
446 | } | ||
447 | |||
448 | template<> template<> | ||
449 | void string_index_object_t::test<27>() | ||
450 | { | ||
451 | LLString lhs_str("PROgraM12files"); | ||
452 | LLString rhs_str("PROgram12Files"); | ||
453 | ensure("compareDict 1 failed", LLString::compareDict(lhs_str, rhs_str) < 0); | ||
454 | ensure("precedesDict 1 failed", LLString::precedesDict(lhs_str, rhs_str) == TRUE); | ||
455 | |||
456 | lhs_str = "PROgram12Files"; | ||
457 | rhs_str = "PROgram12Files"; | ||
458 | ensure("compareDict 2 failed", LLString::compareDict(lhs_str, rhs_str) == 0); | ||
459 | ensure("precedesDict 2 failed", LLString::precedesDict(lhs_str, rhs_str) == FALSE); | ||
460 | |||
461 | lhs_str = "PROgram12Files"; | ||
462 | rhs_str = "PROgRAM12FILES"; | ||
463 | ensure("compareDict 3 failed", LLString::compareDict(lhs_str, rhs_str) > 0); | ||
464 | ensure("precedesDict 3 failed", LLString::precedesDict(lhs_str, rhs_str) == FALSE); | ||
465 | } | ||
466 | |||
467 | template<> template<> | ||
468 | void string_index_object_t::test<28>() | ||
469 | { | ||
470 | char str1[] = "First String..."; | ||
471 | char str2[100]; | ||
472 | |||
473 | LLString::copy(str2, str1, 100); | ||
474 | ensure("LLString::copy with enough dest lenght failed", strcmp(str2, str1) == 0); | ||
475 | LLString::copy(str2, str1, sizeof("First")); | ||
476 | ensure("LLString::copy with less dest lenght failed", strcmp(str2, "First") == 0); | ||
477 | } | ||
478 | |||
479 | template<> template<> | ||
480 | void string_index_object_t::test<29>() | ||
481 | { | ||
482 | LLString str1 = "This is the sentence..."; | ||
483 | LLString str2 = "This is the "; | ||
484 | LLString str3 = "first "; | ||
485 | LLString str4 = "This is the first sentence..."; | ||
486 | LLString str5 = "This is the sentence...first "; | ||
487 | LLString dest; | ||
488 | |||
489 | dest = str1; | ||
490 | LLString::copyInto(dest, str3, str2.length()); | ||
491 | ensure("LLString::copyInto insert failed", dest == str4); | ||
492 | |||
493 | dest = str1; | ||
494 | LLString::copyInto(dest, str3, dest.length()); | ||
495 | ensure("LLString::copyInto append failed", dest == str5); | ||
496 | } | ||
497 | } | ||
498 | |||