inventory.cpp

Go to the documentation of this file.
00001 
00034 #include "linden_common.h"
00035 #include "lltut.h"
00036 #include "llinventory.h"
00037 #include "llsd.h"
00038 
00039 LLPointer<LLInventoryItem> create_random_inventory_item()
00040 {
00041         LLUUID item_id;
00042         item_id.generate();
00043         LLUUID parent_id;
00044         parent_id.generate();
00045         LLPermissions perm;
00046         LLUUID creator_id;
00047         creator_id.generate();
00048         LLUUID owner_id;
00049         owner_id.generate();
00050         LLUUID last_owner_id;
00051         last_owner_id.generate();
00052         LLUUID group_id;
00053         group_id.generate();
00054         perm.init(creator_id, owner_id, last_owner_id, group_id);
00055         perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
00056         LLUUID asset_id;
00057         asset_id.generate();
00058         S32 price = rand();
00059         LLSaleInfo sale_info(LLSaleInfo::FS_COPY, price);
00060         U32 flags = rand();
00061         S32 creation = time(NULL);
00062 
00063         LLPointer<LLInventoryItem> item = new LLInventoryItem(
00064                 item_id,
00065                 parent_id,
00066                 perm,
00067                 asset_id,
00068                 LLAssetType::AT_OBJECT,
00069                 LLInventoryType::IT_ATTACHMENT,
00070                 "Sample Object",
00071                 "Used for Testing",
00072                 sale_info,
00073                 flags,
00074                 creation);
00075         return item;
00076 }
00077 
00078 LLPointer<LLInventoryCategory> create_random_inventory_cat()
00079 {
00080         LLUUID item_id;
00081         item_id.generate();
00082         LLUUID parent_id;
00083         parent_id.generate();
00084 
00085         LLPointer<LLInventoryCategory> cat = new LLInventoryCategory(
00086                 item_id,
00087                 parent_id,
00088                 LLAssetType::AT_NONE,
00089                 "Sample category");
00090         return cat;
00091 }
00092 
00093 namespace tut
00094 {
00095         struct inventory_data
00096         {
00097         };
00098         typedef test_group<inventory_data> inventory_test;
00099         typedef inventory_test::object inventory_object;
00100         tut::inventory_test inv("llinventory");
00101 
00102 //***class LLInventoryType***//
00103 
00104 
00105         template<> template<>
00106         void inventory_object::test<1>()
00107         {
00108                 LLInventoryType::EType retType =  LLInventoryType::lookup("sound");
00109                 ensure("1.LLInventoryType::lookup(char*) failed", retType == LLInventoryType::IT_SOUND);
00110 
00111                 retType = LLInventoryType::lookup("snapshot");
00112                 ensure("2.LLInventoryType::lookup(char*) failed", retType == LLInventoryType::IT_SNAPSHOT);
00113         }
00114 
00115         template<> template<>
00116         void inventory_object::test<2>()
00117         {
00118                 const char* retType =  LLInventoryType::lookup(LLInventoryType::IT_CALLINGCARD);
00119                 ensure("1.LLInventoryType::lookup(EType) failed", 0 == strcmp(retType, "callcard")); 
00120 
00121                 retType = LLInventoryType::lookup(LLInventoryType::IT_LANDMARK);
00122                 ensure("2.LLInventoryType::lookup(EType) failed", 0 == strcmp(retType, "landmark"));
00123                 
00124         }
00125 
00126         template<> template<>
00127         void inventory_object::test<3>()
00128         {
00129                 static const char* retType =  LLInventoryType::lookupHumanReadable(LLInventoryType::IT_CALLINGCARD);
00130                 ensure("1.LLInventoryType::lookupHumanReadable(EType) failed", 0 == strcmp(retType, "calling card")); 
00131 
00132                 retType =  LLInventoryType::lookupHumanReadable(LLInventoryType::IT_LANDMARK);
00133                 ensure("2.LLInventoryType::lookupHumanReadable(EType) failed", 0 == strcmp(retType, "landmark")); 
00134         }
00135 
00136         template<> template<>
00137         void inventory_object::test<4>()
00138         {
00139                 static LLInventoryType::EType retType =  LLInventoryType::defaultForAssetType(LLAssetType::AT_TEXTURE);
00140                 ensure("1.LLInventoryType::defaultForAssetType(LLAssetType EType) failed", retType == LLInventoryType::IT_TEXTURE);
00141 
00142                 retType =  LLInventoryType::defaultForAssetType(LLAssetType::AT_LANDMARK);
00143                 ensure("2.LLInventoryType::defaultForAssetType(LLAssetType EType) failed", retType == LLInventoryType::IT_LANDMARK);
00144         }
00145 
00146 //*****class LLInventoryItem*****//
00147 
00148         template<> template<>
00149         void inventory_object::test<5>()
00150         {
00151                 LLPointer<LLInventoryItem> src = create_random_inventory_item();
00152                 LLSD sd = ll_create_sd_from_inventory_item(src);
00153                 //llinfos << "sd: " << *sd << llendl;
00154                 LLPointer<LLInventoryItem> dst = ll_create_item_from_sd(sd);
00155                 ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src->getUUID());
00156                 ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
00157                 ensure_equals("3.name::getName() failed", dst->getName(), src->getName());
00158                 ensure_equals("4.type::getType() failed", dst->getType(), src->getType());
00159                 
00160                 ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src->getPermissions());
00161                 ensure_equals("6.description::getDescription() failed", dst->getDescription(), src->getDescription());
00162                 ensure_equals("7.sale type::getSaleType() failed", dst->getSaleInfo().getSaleType(), src->getSaleInfo().getSaleType());
00163                 ensure_equals("8.sale price::getSalePrice() failed", dst->getSaleInfo().getSalePrice(), src->getSaleInfo().getSalePrice());
00164                 ensure_equals("9.asset id::getAssetUUID() failed", dst->getAssetUUID(), src->getAssetUUID());
00165                 ensure_equals("10.inventory type::getInventoryType() failed", dst->getInventoryType(), src->getInventoryType());
00166                 ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src->getFlags());
00167                 ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src->getCreationDate());
00168 
00169                 LLUUID new_item_id, new_parent_id;
00170                 new_item_id.generate();
00171                 src->setUUID(new_item_id);
00172                 
00173                 new_parent_id.generate();
00174                 src->setParent(new_parent_id);
00175                 
00176                 LLString new_name = "LindenLab";
00177                 src->rename(new_name);
00178                 
00179                 src->setType(LLAssetType::AT_SOUND);
00180 
00181                 LLUUID new_asset_id;
00182                 new_asset_id.generate();
00183                 
00184                 src->setAssetUUID(new_asset_id);
00185                 LLString new_desc = "SecondLife Testing";
00186                 src->setDescription(new_desc);
00187                 
00188                 S32 new_price = rand();
00189                 LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
00190                 src->setSaleInfo(new_sale_info);
00191 
00192                 U32 new_flags = rand();
00193                 S32 new_creation = time(NULL);
00194 
00195                 LLPermissions new_perm;
00196 
00197                 LLUUID new_creator_id;
00198                 new_creator_id.generate();
00199         
00200                 LLUUID new_owner_id;
00201                 new_owner_id.generate();
00202 
00203                 LLUUID last_owner_id;
00204                 last_owner_id.generate();
00205 
00206                 LLUUID new_group_id;
00207                 new_group_id.generate();
00208                 new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
00209                 new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
00210                 src->setPermissions(new_perm);
00211 
00212                 src->setInventoryType(LLInventoryType::IT_SOUND);
00213                 src->setFlags(new_flags);
00214                 src->setCreationDate(new_creation);
00215 
00216                 sd = ll_create_sd_from_inventory_item(src);
00217                 //llinfos << "sd: " << *sd << llendl;
00218                 dst = ll_create_item_from_sd(sd);
00219                 ensure_equals("13.item id::getUUID() failed", dst->getUUID(), src->getUUID());
00220                 ensure_equals("14.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
00221                 ensure_equals("15.name::getName() failed", dst->getName(), src->getName());
00222                 ensure_equals("16.type::getType() failed", dst->getType(), src->getType());
00223                 
00224                 ensure_equals("17.permissions::getPermissions() failed", dst->getPermissions(), src->getPermissions());
00225                 ensure_equals("18.description::getDescription() failed", dst->getDescription(), src->getDescription());
00226                 ensure_equals("19.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src->getSaleInfo().getSaleType());
00227                 ensure_equals("20.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src->getSaleInfo().getSalePrice());
00228                 ensure_equals("21.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src->getAssetUUID());
00229                 ensure_equals("22.inventory type::getInventoryType() failed type", dst->getInventoryType(), src->getInventoryType());
00230                 ensure_equals("23.flags::getFlags() failed", dst->getFlags(), src->getFlags());
00231                 ensure_equals("24.creation::getCreationDate() failed", dst->getCreationDate(), src->getCreationDate());
00232                 
00233         }
00234 
00235         template<> template<>
00236         void inventory_object::test<6>()
00237         {
00238                 LLPointer<LLInventoryItem> src = create_random_inventory_item();
00239                 
00240                 LLUUID new_item_id, new_parent_id;
00241                 new_item_id.generate();
00242                 src->setUUID(new_item_id);
00243                 
00244                 new_parent_id.generate();
00245                 src->setParent(new_parent_id);
00246                 
00247                 LLString new_name = "LindenLab";
00248                 src->rename(new_name);
00249                 
00250                 src->setType(LLAssetType::AT_SOUND);
00251 
00252                 LLUUID new_asset_id;
00253                 new_asset_id.generate();
00254                 
00255                 src->setAssetUUID(new_asset_id);
00256                 LLString new_desc = "SecondLife Testing";
00257                 src->setDescription(new_desc);
00258                 
00259                 S32 new_price = rand();
00260                 LLSaleInfo new_sale_info(LLSaleInfo::FS_COPY, new_price);
00261                 src->setSaleInfo(new_sale_info);
00262 
00263                 U32 new_flags = rand();
00264                 S32 new_creation = time(NULL);
00265 
00266                 LLPermissions new_perm;
00267 
00268                 LLUUID new_creator_id;
00269                 new_creator_id.generate();
00270         
00271                 LLUUID new_owner_id;
00272                 new_owner_id.generate();
00273 
00274                 LLUUID last_owner_id;
00275                 last_owner_id.generate();
00276 
00277                 LLUUID new_group_id;
00278                 new_group_id.generate();
00279                 new_perm.init(new_creator_id, new_owner_id, last_owner_id, new_group_id);
00280                 new_perm.initMasks(PERM_ALL, PERM_ALL, PERM_COPY, PERM_COPY, PERM_MODIFY | PERM_COPY);
00281                 src->setPermissions(new_perm);
00282 
00283                 src->setInventoryType(LLInventoryType::IT_SOUND);
00284                 src->setFlags(new_flags);
00285                 src->setCreationDate(new_creation);
00286 
00287                 LLSD sd = ll_create_sd_from_inventory_item(src);
00288                 LLPointer<LLInventoryItem> dst = ll_create_item_from_sd(sd);
00289 
00290 
00291                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00292                 src1->copy(src);
00293                 src1->clone(src);
00294                 
00295                 ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src1->getUUID());
00296                 ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src1->getParentUUID());
00297                 ensure_equals("3.name::getName() failed", dst->getName(), src1->getName());
00298                 ensure_equals("4.type::getType() failed", dst->getType(), src1->getType());
00299                 
00300                 ensure_equals("5.permissions::getPermissions() failed", dst->getPermissions(), src1->getPermissions());
00301                 ensure_equals("6.description::getDescription() failed", dst->getDescription(), src1->getDescription());
00302                 ensure_equals("7.sale type::getSaleType() failed type", dst->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
00303                 ensure_equals("8.sale price::getSalePrice() failed price", dst->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
00304                 ensure_equals("9.asset id::getAssetUUID() failed id", dst->getAssetUUID(), src1->getAssetUUID());
00305                 ensure_equals("10.inventory type::getInventoryType() failed type", dst->getInventoryType(), src1->getInventoryType());
00306                 ensure_equals("11.flags::getFlags() failed", dst->getFlags(), src1->getFlags());
00307                 ensure_equals("12.creation::getCreationDate() failed", dst->getCreationDate(), src1->getCreationDate());
00308 
00309                 LLPointer<LLInventoryItem> src2;
00310                 src1->clone(src2);
00311                 
00312                 ensure_not_equals("13.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00313                 ensure_equals("14.parent::getParentUUID() failed", src2->getParentUUID(), src1->getParentUUID());
00314                 ensure_equals("15.name::getName() failed", src2->getName(), src1->getName());
00315                 ensure_equals("16.type::getType() failed", src2->getType(), src1->getType());
00316                 
00317                 ensure_equals("17.permissions::getPermissions() failed", src2->getPermissions(), src1->getPermissions());
00318                 ensure_equals("18.description::getDescription() failed", src2->getDescription(), src1->getDescription());
00319                 ensure_equals("19.sale type::getSaleType() failed type", src2->getSaleInfo().getSaleType(), src1->getSaleInfo().getSaleType());
00320                 ensure_equals("20.sale price::getSalePrice() failed price", src2->getSaleInfo().getSalePrice(), src1->getSaleInfo().getSalePrice());
00321                 ensure_equals("21.asset id::getAssetUUID() failed id", src2->getAssetUUID(), src1->getAssetUUID());
00322                 ensure_equals("22.inventory type::getInventoryType() failed type", src2->getInventoryType(), src1->getInventoryType());
00323                 ensure_equals("23.flags::getFlags() failed", src2->getFlags(), src1->getFlags());
00324                 ensure_equals("24.creation::getCreationDate() failed", src2->getCreationDate(), src1->getCreationDate());
00325 
00326 
00327         }
00328 
00329         template<> template<>
00330         void inventory_object::test<7>()
00331         {
00332                 FILE* fp = fopen("linden_file.dat","w+");
00333                 if(!fp)
00334                 {
00335                         llerrs << "file could not be opened\n" << llendl;
00336                         return;
00337                 }
00338                         
00339                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00340                 src1->exportFile(fp, TRUE);
00341                 fclose(fp);
00342 
00343                 LLPointer<LLInventoryItem> src2 = new LLInventoryItem();        
00344                 fp = fopen("linden_file.dat","r+");
00345                 if(!fp)
00346                 {
00347                         llerrs << "file could not be opened\n" << llendl;
00348                         return;
00349                 }
00350                 
00351                 src2->importFile(fp);
00352                 fclose(fp);
00353                 
00354                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00355                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00356                 ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
00357                 ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
00358                 ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
00359                 ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
00360                 ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
00361                 ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
00362                 ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());                                
00363                 ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
00364                         
00365         }
00366 
00367         template<> template<>
00368         void inventory_object::test<8>()
00369         {
00370                         
00371                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00372 
00373                 std::ostringstream ostream;
00374                 src1->exportLegacyStream(ostream, TRUE);
00375                 
00376                 std::istringstream istream(ostream.str());
00377                 LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
00378                 src2->importLegacyStream(istream);
00379                                         
00380                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00381                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00382                 ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
00383                 ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
00384                 ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
00385                 ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
00386                 ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
00387                 ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
00388                 ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());                                
00389                 ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
00390                 
00391                 
00392         }
00393 
00394         template<> template<>
00395         void inventory_object::test<9>()
00396         {
00397 // exportFileXML seg-faults for some reason. LLXMLNode is teh suck.
00398 #if 0           
00399                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00400                 LLXMLNode* x_node = src1->exportFileXML(TRUE);
00401 
00402                 LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
00403                 src2->importXML(x_node);
00404                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00405                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00406                 ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
00407                 ensure_equals("4.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
00408                 ensure_equals("5.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
00409                 ensure_equals("6.type::getType() failed", src1->getType(), src2->getType());
00410                 ensure_equals("7.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
00411                 ensure_equals("8.name::getName() failed", src1->getName(), src2->getName());
00412                 ensure_equals("9.description::getDescription() failed", src1->getDescription(), src2->getDescription());                                
00413                 ensure_equals("10.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
00414 #endif          
00415         }
00416                 
00417         template<> template<>
00418         void inventory_object::test<10>()
00419         {
00420                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00421                 U8* bin_bucket = new U8[300];
00422                 S32 bin_bucket_size = src1->packBinaryBucket(bin_bucket, NULL);
00423 
00424                 LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
00425                 src2->unpackBinaryBucket(bin_bucket, bin_bucket_size);
00426 
00427                 ensure_equals("1.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
00428                 ensure_equals("2.sale type::getSaleType() failed type", src1->getSaleInfo().getSaleType(), src2->getSaleInfo().getSaleType());
00429                 ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
00430                 ensure_equals("4.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
00431                 ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
00432                 ensure_equals("6.description::getDescription() failed", src1->getDescription(), src2->getDescription());                                
00433                 ensure_equals("7.flags::getFlags() failed", src1->getFlags(), src2->getFlags());
00434         
00435         }
00436         
00437         template<> template<>
00438         void inventory_object::test<11>()
00439         {
00440                 LLPointer<LLInventoryItem> src1 = create_random_inventory_item();
00441                 LLSD retSd = src1->asLLSD();
00442                 LLPointer<LLInventoryItem> src2 = new LLInventoryItem();
00443                 src2->fromLLSD(retSd);
00444 
00445                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00446                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00447                 ensure_equals("3.permissions::getPermissions() failed", src1->getPermissions(), src2->getPermissions());
00448                 ensure_equals("4.asset id::getAssetUUID() failed id", src1->getAssetUUID(), src2->getAssetUUID());
00449                 ensure_equals("5.type::getType() failed", src1->getType(), src2->getType());
00450                 ensure_equals("6.inventory type::getInventoryType() failed type", src1->getInventoryType(), src2->getInventoryType());
00451                 ensure_equals("7.flags::getFlags() failed", src1->getFlags(), src2->getFlags());
00452                 ensure_equals("8.sale type::getSaleType() failed type", src1->getSaleInfo().getSaleType(), src2->getSaleInfo().getSaleType());
00453                 ensure_equals("9.sale price::getSalePrice() failed price", src1->getSaleInfo().getSalePrice(), src2->getSaleInfo().getSalePrice());
00454                 ensure_equals("10.name::getName() failed", src1->getName(), src2->getName());
00455                 ensure_equals("11.description::getDescription() failed", src1->getDescription(), src2->getDescription());                               
00456 
00457 
00458                 skip_fail("12.creation::getCreationDate()");
00459                 ensure_equals("12.creation::getCreationDate() failed", src1->getCreationDate(), src2->getCreationDate());
00460         }       
00461 
00462 //******class LLInventoryCategory*******//
00463 
00464         template<> template<>
00465         void inventory_object::test<12>()
00466         {
00467                 LLPointer<LLInventoryCategory> src = create_random_inventory_cat();
00468                 LLSD sd = ll_create_sd_from_inventory_category(src);
00469                 LLPointer<LLInventoryCategory> dst = ll_create_category_from_sd(sd);
00470                 
00471                 ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src->getUUID());
00472                 ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
00473                 ensure_equals("3.name::getName() failed", dst->getName(), src->getName());
00474                 ensure_equals("4.type::getType() failed", dst->getType(), src->getType());
00475                 ensure_equals("5.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());
00476 
00477                 src->setPreferredType( LLAssetType::AT_TEXTURE);
00478                 sd = ll_create_sd_from_inventory_category(src);
00479                 dst = ll_create_category_from_sd(sd);
00480                 ensure_equals("6.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());
00481 
00482                 
00483         }
00484 
00485         template<> template<>
00486         void inventory_object::test<13>()
00487         {
00488                 FILE* fp = fopen("linden_file.dat","w");
00489                 if(!fp)
00490                 {
00491                         llerrs << "file coudnt be opened\n" << llendl;
00492                         return;
00493                 }
00494                         
00495                 LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();
00496                 src1->exportFile(fp, TRUE);
00497                 fclose(fp);
00498 
00499                 LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();        
00500                 fp = fopen("linden_file.dat","r");
00501                 if(!fp)
00502         {
00503                         llerrs << "file coudnt be opened\n" << llendl;
00504                         return;
00505                 }
00506                 
00507                 src2->importFile(fp);
00508                 fclose(fp);
00509 
00510                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00511                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00512                 ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
00513                 ensure_equals("4.preferred type::getPreferredType() failed", src1->getPreferredType(), src2->getPreferredType());
00514                 ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
00515         }
00516 
00517         template<> template<>
00518         void inventory_object::test<14>()
00519         {
00520                 LLPointer<LLInventoryCategory> src1 = create_random_inventory_cat();
00521 
00522                 std::ostringstream ostream;
00523                 src1->exportLegacyStream(ostream, TRUE);
00524 
00525                 std::istringstream istream(ostream.str());
00526                 LLPointer<LLInventoryCategory> src2 = new LLInventoryCategory();
00527                 src2->importLegacyStream(istream);
00528                                         
00529                 ensure_equals("1.item id::getUUID() failed", src1->getUUID(), src2->getUUID());
00530                 ensure_equals("2.parent::getParentUUID() failed", src1->getParentUUID(), src2->getParentUUID());
00531                 ensure_equals("3.type::getType() failed", src1->getType(), src2->getType());
00532                 ensure_equals("4.preferred type::getPreferredType() failed", src1->getPreferredType(), src2->getPreferredType());
00533                 ensure_equals("5.name::getName() failed", src1->getName(), src2->getName());
00534                         
00535         }
00536 }

Generated on Thu Jul 1 06:08:17 2010 for Second Life Viewer by  doxygen 1.4.7