aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/inventory.cpp
blob: 8cd356b9f76de1b6fce0ac56929aa4e4999f4d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/** 
 * @file inventory.cpp
 * @author Phoenix
 * @date 2005-11-15
 * @brief Functions for inventory test framework
 *
 * $LicenseInfo:firstyear=2005&license=viewergpl$
 * 
 * Copyright (c) 2005-2009, Linden Research, Inc.
 * 
 * Second Life Viewer Source Code
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at
 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#include "linden_common.h"
#include "lltut.h"
#include "llinventory.h"
#include "llsd.h"

#if LL_WINDOWS
// disable unreachable code warnings
#pragma warning(disable: 4702)
#endif

LLPointer<LLInventoryItem> create_random_inventory_item()
{
	LLUUID item_id;
	item_id.generate();
	LLUUID parent_id;
	parent_id.generate();
	LLPermissions perm;
	LLUUID creator_id;
	creator_id.generate();
	LLUUID owner_id;
	owner_id.generate();
	LLUUID last_owner_id;
	last_owner_id.generate();
	LLUUID group_id;
	group_id.generate();
	perm.init(creator_id, owner_id, last_owner_id, group_id);
	perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
	LLUUID asset_id;
	asset_id.generate();
	S32 price = rand();
	LLSaleInfo sale_info(LLSaleInfo::FS_COPY, price);
	U32 flags = rand();
	S32 creation = time(NULL);

	LLPointer<LLInventoryItem> item = new LLInventoryItem(
		item_id,
		parent_id,
		perm,
		asset_id,
		LLAssetType::AT_OBJECT,
		LLInventoryType::IT_ATTACHMENT,
		std::string("Sample Object"),
		std::string("Used for Testing"),
		sale_info,
		flags,
		creation);
	return item;
}

LLPointer<LLInventoryCategory> create_random_inventory_cat()
{
	LLUUID item_id;
	item_id.generate();
	LLUUID parent_id;
	parent_id.generate();

	LLPointer<LLInventoryCategory> cat = new LLInventoryCategory(
		item_id,
		parent_id,
		LLAssetType::AT_NONE,
		std::string("Sample category"));
	return cat;
}

namespace tut
{
	struct inventory_data
	{
	};
	typedef test_group<inventory_data> inventory_test;
	typedef inventory_test::object inventory_object;
	tut::inventory_test inv("llinventory");

//***class LLInventoryType***//


	template<> template<>
	void inventory_object::test<1>()
	{
		LLInventoryType::EType retType =  LLInventoryType::lookup(std::string("sound"));
		ensure("1.LLInventoryType::lookup(char*) failed", retType == LLInventoryType::IT_SOUND);

		retType = LLInventoryType::lookup(std::string("snapshot"));
		ensure("2.LLInventoryType::lookup(char*) failed", retType == LLInventoryType::IT_SNAPSHOT);
	}

	template<> template<>
	void inventory_object::test<2>()
	{
		const char* retType =  LLInventoryType::lookup(LLInventoryType::IT_CALLINGCARD);
		ensure("1.LLInventoryType::lookup(EType) failed", 0 == strcmp(retType, "callcard")); 

		retType = LLInventoryType::lookup(LLInventoryType::IT_LANDMARK);
		ensure("2.LLInventoryType::lookup(EType) failed", 0 == strcmp(retType, "landmark"));
		
	}

	template<> template<>
	void inventory_object::test<3>()
	{
		static const char* retType =  LLInventoryType::lookupHumanReadable(LLInventoryType::IT_CALLINGCARD);
		ensure("1.LLInventoryType::lookupHumanReadable(EType) failed", 0 == strcmp(retType, "calling card")); 

		retType =  LLInventoryType::lookupHumanReadable(LLInventoryType::IT_LANDMARK);
		ensure("2.LLInventoryType::lookupHumanReadable(EType) failed", 0 == strcmp(retType, "landmark")); 
	}

	template<> template<>
	void inventory_object::test<4>()
	{
		static LLInventoryType::EType retType =  LLInventoryType::defaultForAssetType(LLAssetType::AT_TEXTURE);
		ensure("1.LLInventoryType::defaultForAssetType(LLAssetType EType) failed", retType == LLInventoryType::IT_TEXTURE);

		retType =  LLInventoryType::defaultForAssetType(LLAssetType::AT_LANDMARK);
		ensure("2.LLInventoryType::defaultForAssetType(LLAssetType EType) failed", retType == LLInventoryType::IT_LANDMARK);
	}

//*****class LLInventoryItem*****//

	template<> template<>
	void inventory_object::test<5>()
	{
		LLPointer<LLInventoryItem> src = create_random_inventory_item();
		LLSD sd = ll_create_sd_from_inventory_item(src);
		//llinfos << "sd: " << *sd << llendl;
		LLPointer<LLInventoryItem> dst = ll_create_item_from_sd(sd);
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src->getType());
		
		ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src->getPermissions());
		ensure_equals("6.description::getDescription() failed", dst->getDescription(), src->getDescription());
		ensure_equals("7.sale type::getSaleType() failed", dst->getSaleInfo().getSaleType(), src->getSaleInfo().getSaleType());
		ensure_equals("8.sale price::getSalePrice() failed", dst->getSaleInfo().getSalePrice(), src->getSaleInfo().getSalePrice());
		ensure_equals("9.asset id::getAssetUUID() failed", dst->getAssetUUID(), src->getAssetUUID());
		ensure_equals("10.inventory type::getInventoryType() failed", dst->getInventoryType(), src->getInventoryType());
		ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src->getFlags());
		ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src->getCreationDate());

		LLUUID new_item_id, new_parent_id;
		new_item_id.generate();
		src->setUUID(new_item_id);
		
		new_parent_id.generate();
		src->setParent(new_parent_id);
		
		std::string new_name = "LindenLab";
		src->rename(new_name);
		
		src->setType(LLAssetType::AT_SOUND);

		LLUUID new_asset_id;
		new_asset_id.generate();
		
		src->setAssetUUID(new_asset_id);
		std::string new_desc = "SecondLife Testing";
		src->setDescription(new_desc);
		
		S32 new_price = rand();
		LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
		src->setSaleInfo(new_sale_info);

		U32 new_flags = rand();
		S32 new_creation = time(NULL);

		LLPermissions new_perm;

		LLUUID new_creator_id;
		new_creator_id.generate();
	
		LLUUID new_owner_id;
		new_owner_id.generate();

		LLUUID last_owner_id;
		last_owner_id.generate();

		LLUUID new_group_id;
		new_group_id.generate();
		new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
		new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
		src->setPermissions(new_perm);

		src->setInventoryType(LLInventoryType::IT_SOUND);
		src->setFlags(new_flags);
		src->setCreationDate(new_creation);

		sd = ll_create_sd_from_inventory_item(src);
		//llinfos << "sd: " << *sd << llendl;
		dst = ll_create_item_from_sd(sd);
		ensure_equals("13.item id::getUUID() failed", dst->getUUID(), src->getUUID());
		ensure_equals("14.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
		ensure_equals("15.name::getName() failed", dst->getName(), src->getName());
		ensure_equals("16.type::getType() failed", dst->getType(), src->getType());
		
		ensure_equals("17.permissions::getPermissions() failed", dst->getPermissions(), src->getPermissions());
		ensure_equals("18.description::getDescription() failed", dst->getDescription(), src->getDescription());
		ensure_equals("19.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src->getSaleInfo().getSaleType());
		ensure_equals("20.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src->getSaleInfo().getSalePrice());
		ensure_equals("21.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src->getAssetUUID());
		ensure_equals("22.inventory type::getInventoryType() failed type", dst->getInventoryType(), src->getInventoryType());
		ensure_equals("23.flags::getFlags() failed", dst->getFlags(), src->getFlags());
		ensure_equals("24.creation::getCreationDate() failed", dst->getCreationDate(), src->getCreationDate());
		
	}

	template<> template<>
	void inventory_object::test<6>()
	{
		LLPointer<LLInventoryItem> src = create_random_inventory_item();
		
		LLUUID new_item_id, new_parent_id;
		new_item_id.generate();
		src->setUUID(new_item_id);
		
		new_parent_id.generate();
		src->setParent(new_parent_id);
		
		std::string new_name = "LindenLab";
		src->rename(new_name);
		
		src->setType(LLAssetType::AT_SOUND);

		LLUUID new_asset_id;
		new_asset_id.generate();
		
		src->setAssetUUID(new_asset_id);
		std::string new_desc = "SecondLife Testing";
		src->setDescription(new_desc);
		
		S32 new_price = rand();
		LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
		src->setSaleInfo(new_sale_info);

		U32 new_flags = rand();
		S32 new_creation = time(NULL);

		LLPermissions new_perm;

		LLUUID new_creator_id;
		new_creator_id.generate();
	
		LLUUID new_owner_id;
		new_owner_id.generate();

		LLUUID last_owner_id;
		last_owner_id.generate();

		LLUUID new_group_id;
		new_group_id.generate();
		new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
		new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
		src->setPermissions(new_perm);

		src->setInventoryType(LLInventoryType::IT_SOUND);
		src->setFlags(new_flags);
		src->setCreationDate(new_creation);

		LLSD sd = ll_create_sd_from_inventory_item(src);
		LLPointer<LLInventoryItem> dst = ll_create_item_from_sd(sd);


		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		src1->copyItem(src);
		src1->cloneItem(src);
		
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src1->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src1->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src1->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src1->getType());
		
		ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src1->getPermissions());
		ensure_equals("6.description::getDescription() failed", dst->getDescription(), src1->getDescription());
		ensure_equals("7.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
		ensure_equals("8.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
		ensure_equals("9.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src1->getAssetUUID());
		ensure_equals("10.inventory type::getInventoryType() failed type", dst->getInventoryType(), src1->getInventoryType());
		ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src1->getFlags());
		ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src1->getCreationDate());

		LLPointer<LLInventoryItem> src2;
		src1->cloneItem(src2);
		
		ensure_not_equals("13.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("14.parent::getParentUUID() failed", src2->getParentUUID(), src1->getParentUUID());
		ensure_equals("15.name::getName() failed", src2->getName(), src1->getName());
		ensure_equals("16.type::getType() failed", src2->getType(), src1->getType());
		
		ensure_equals("17.permissions::getPermissions() failed", src2->getPermissions(), src1->getPermissions());
		ensure_equals("18.description::getDescription() failed", src2->getDescription(), src1->getDescription());
		ensure_equals("19.sale type::getSaleType() failed type", src2->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
		ensure_equals("20.sale price::getSalePrice() failed price", src2->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
		ensure_equals("21.asset id::getAssetUUID() failed id", src2->getAssetUUID(), src1->getAssetUUID());
		ensure_equals("22.inventory type::getInventoryType() failed type", src2->getInventoryType(), src1->getInventoryType());
		ensure_equals("23.flags::getFlags() failed", src2->getFlags(), src1->getFlags());
		ensure_equals("24.creation::getCreationDate() failed", src2->getCreationDate(), src1->getCreationDate());


	}

	template<> template<>
	void inventory_object::test<7>()
	{
		LLFILE* fp = LLFile::fopen("linden_file.dat","w+");
		if(!fp)
		{
			llerrs << "file could not be opened\n" << llendl;
			return;
		}
			
		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		src1->exportFile(fp, TRUE);
		fclose(fp);

		LLPointer<LLInventoryItem> src2 = new LLInventoryItem();	
		fp = LLFile::fopen("linden_file.dat","r+");
		if(!fp)
		{
			llerrs << "file could not be opened\n" << llendl;
			return;
		}
		
		src2->importFile(fp);
		fclose(fp);
		
		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
		ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
		ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
		ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
		ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
		ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
		ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());				
		ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
			
	}

	template<> template<>
	void inventory_object::test<8>()
	{
			
		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();

		std::ostringstream ostream;
		src1->exportLegacyStream(ostream, TRUE);
		
		std::istringstream istream(ostream.str());
		LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
		src2->importLegacyStream(istream);
					
		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
		ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
		ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
		ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
		ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
		ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
		ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());				
		ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
		
		
	}

	template<> template<>
	void inventory_object::test<9>()
	{
// exportFileXML seg-faults for some reason. LLXMLNode is teh suck.
#if 0		
		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		LLXMLNode* x_node = src1->exportFileXML(TRUE);

		LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
		src2->importXML(x_node);
		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
		ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
		ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
		ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
		ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
		ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
		ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());				
		ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
#endif		
	}
		
	template<> template<>
	void inventory_object::test<10>()
	{
		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		U8* bin_bucket = new U8[300];
		S32 bin_bucket_size = src1->packBinaryBucket(bin_bucket, NULL);

		LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
		src2->unpackBinaryBucket(bin_bucket, bin_bucket_size);

		ensure_equals("1.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
		ensure_equals("2.sale type::getSaleType() failed type", src1->getSaleInfo().getSaleType(), src2->getSaleInfo().getSaleType());
		ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("4.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
		ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
		ensure_equals("6.description::getDescription() failed", src1->getDescription(), src2->getDescription());				
		ensure_equals("7.flags::getFlags() failed", src1->getFlags(), src2->getFlags());
	
	}
	
	template<> template<>
	void inventory_object::test<11>()
	{
		LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
		LLSD retSd = src1->asLLSD();
		LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
		src2->fromLLSD(retSd);

		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
		ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
		ensure_equals("4.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
		ensure_equals("5.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("6.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
		ensure_equals("7.flags::getFlags() failed", src1->getFlags(), src2->getFlags());
		ensure_equals("8.sale type::getSaleType() failed type", src1->getSaleInfo().getSaleType(), src2->getSaleInfo().getSaleType());
		ensure_equals("9.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
		ensure_equals("10.name::getName() failed", src1->getName(), src2->getName());
		ensure_equals("11.description::getDescription() failed", src1->getDescription(), src2->getDescription());				
		ensure_equals("12.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
	}	

//******class LLInventoryCategory*******//

	template<> template<>
	void inventory_object::test<12>()
	{
		LLPointer<LLInventoryCategory> src = create_random_inventory_cat();
		LLSD sd = ll_create_sd_from_inventory_category(src);
		LLPointer<LLInventoryCategory> dst = ll_create_category_from_sd(sd);
		
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src->getType());
		ensure_equals("5.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());

		src->setPreferredType( LLAssetType::AT_TEXTURE);
		sd = ll_create_sd_from_inventory_category(src);
		dst = ll_create_category_from_sd(sd);
		ensure_equals("6.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());

		
	}

	template<> template<>
	void inventory_object::test<13>()
	{
		LLFILE* fp = LLFile::fopen("linden_file.dat","w");
		if(!fp)
		{
			llerrs << "file coudnt be opened\n" << llendl;
			return;
		}
			
		LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();
		src1->exportFile(fp, TRUE);
		fclose(fp);

		LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();	
		fp = LLFile::fopen("linden_file.dat","r");
		if(!fp)
	{
			llerrs << "file coudnt be opened\n" << llendl;
			return;
		}
		
		src2->importFile(fp);
		fclose(fp);

		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
 		ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("4.preferred type::getPreferredType() failed", src1->getPreferredType(), src2->getPreferredType());
		ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
	}

	template<> template<>
	void inventory_object::test<14>()
	{
		LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();

		std::ostringstream ostream;
		src1->exportLegacyStream(ostream, TRUE);

		std::istringstream istream(ostream.str());
		LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();
		src2->importLegacyStream(istream);
					
		ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
		ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
		ensure_equals("4.preferred type::getPreferredType() failed", src1->getPreferredType(), src2->getPreferredType());
		ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
			
	}
}