llpartdata_tut.cpp

Go to the documentation of this file.
00001 
00034 #include <tut/tut.h>
00035 #include "lltut.h"
00036 #include "linden_common.h"
00037 #include "lldatapacker.h"
00038 #include "llpartdata.h"
00039 #include "v3math.h"
00040 #include "llsdserialize.h"
00041 #include "message.h"
00042 
00043 namespace tut
00044 {
00045         
00046         struct partdata_test
00047         {
00048         };
00049         typedef test_group<partdata_test> partdata_test_t;
00050         typedef partdata_test_t::object partdata_test_object_t;
00051         tut::partdata_test_t tut_partdata_test("partdata_test");
00052 
00053         template<> template<>
00054         void partdata_test_object_t::test<1>()
00055         {
00056                 LLPartData llpdata,llpdata1;
00057                 U8 pkbuf[128];
00058 
00059                 llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK |
00060                 LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK |
00061                 LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK |
00062                 LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK);
00063 
00064                 llpdata.setMaxAge(29.3f);
00065 
00066                 LLVector3 llvec1(1.0f, .5f, .25f);
00067                 llpdata.setStartColor(llvec1);
00068                 llpdata.setStartAlpha(.7f);
00069 
00070                 LLVector3 llvec2(.2f, .3f, 1.0f);
00071                 llpdata.setEndColor(llvec2);
00072                 llpdata.setEndAlpha(1.0f);
00073 
00074                 llpdata.setStartScale(3.23f, 4.0f);
00075                 llpdata.setEndScale(2.4678f, 1.0f);
00076 
00077                 LLDataPackerBinaryBuffer dp((U8*)pkbuf, 128);
00078                 llpdata.pack(dp);
00079                 
00080                 S32 cur_size = dp.getCurrentSize();
00081                 
00082                 LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size);
00083                 llpdata1.unpack(dp1);
00084 
00085                 ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags);
00086                 ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8);
00087 
00088                 ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8);
00089                 ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8);
00090                 ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8);
00091                 ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8);
00092 
00093                 ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8);
00094                 ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8);
00095                 ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8);
00096                 ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8);
00097 
00098                 ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5);
00099                 ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5);
00100 
00101                 ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5);
00102                 ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5);
00103         }
00104 
00105 
00106         template<> template<>
00107         void partdata_test_object_t::test<2>()
00108         {
00109                 LLPartData llpdata,llpdata1;
00110 
00111                 llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK |
00112                 LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK |
00113                 LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK |
00114                 LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK);
00115                 
00116                 llpdata.setMaxAge(29.3f);
00117 
00118                 LLVector3 llvec1(1.0f, .5f, .25f);
00119                 llpdata.setStartColor(llvec1);
00120                 llpdata.setStartAlpha(.7f);
00121 
00122                 LLVector3 llvec2(.2f, .3f, 1.0f);
00123                 llpdata.setEndColor(llvec2);
00124                 llpdata.setEndAlpha(1.0f);
00125 
00126                 llpdata.setStartScale(3.23f, 4.0f);
00127                 llpdata.setEndScale(2.4678f, 1.0f);
00128 
00129                 LLSD llsd = llpdata.asLLSD();
00130 
00131                 llpdata1.fromLLSD(llsd);
00132 
00133                 ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags);
00134                 ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8);
00135 
00136                 ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8);
00137                 ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8);
00138                 ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8);
00139                 ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8);
00140 
00141                 ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8);
00142                 ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8);
00143                 ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8);
00144                 ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8);
00145 
00146                 ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5);
00147                 ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5);
00148 
00149                 ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5);
00150                 ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5);
00151         }
00152 
00153 
00154 //*********llpartsysdata***********
00155 
00156         template<> template<>
00157         void partdata_test_object_t::test<3>()
00158         {
00159                 LLPartSysData llpsysdata, llpsysdata1;
00160                 U8 pkbuf[256];
00161                 llpsysdata.setBurstSpeedMin(33.33f);
00162                 ensure("1.mBurstSpeedMin coudnt be set", 33.33f == llpsysdata.mBurstSpeedMin);
00163 
00164                 llpsysdata.setBurstSpeedMax(44.44f); 
00165                 ensure("2.mBurstSpeedMax coudnt be set", 44.44f == llpsysdata.mBurstSpeedMax);
00166 
00167                 llpsysdata.setBurstRadius(45.55f);
00168                 ensure("3.mBurstRadius coudnt be set", 45.55f == llpsysdata.mBurstRadius);
00169 
00170                 LLVector3 llvec(44.44f, 111.11f, -40.4f);
00171                 llpsysdata.setPartAccel(llvec);
00172 
00173                 llpsysdata.mCRC = 0xFFFFFFFF;
00174                 llpsysdata.mFlags = 0x20;
00175 
00176                 llpsysdata.mPattern = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE_EMPTY;
00177 
00178                 llpsysdata.mMaxAge = 99.99f;
00179                 llpsysdata.mStartAge = 18.5f;
00180                 llpsysdata.mInnerAngle = 4.234f;
00181                 llpsysdata.mOuterAngle = 7.123f;
00182                 llpsysdata.mBurstRate  = 245.53f;
00183                 llpsysdata.mBurstPartCount = 0xFF;
00184                 llpsysdata.mAngularVelocity = llvec;
00185 
00186                 llpsysdata.mPartImageID.generate();
00187                 llpsysdata.mTargetUUID.generate();
00188                 
00189                 LLDataPackerBinaryBuffer dp((U8*)pkbuf, 256);
00190                 llpsysdata.pack(dp);
00191                 S32 cur_size = dp.getCurrentSize();
00192                 LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size);
00193                 llpsysdata1.unpack(dp1);
00194 
00195                 ensure("1.mCRC's not equal", llpsysdata.mCRC == llpsysdata1.mCRC);
00196                 ensure("2.mFlags's not equal", llpsysdata.mFlags == llpsysdata1.mFlags);
00197                 ensure("3.mPattern's not equal", llpsysdata.mPattern == llpsysdata1.mPattern);
00198                 ensure_approximately_equals("4.mMaxAge's not equal", llpsysdata.mMaxAge , llpsysdata1.mMaxAge, 8);
00199                 ensure_approximately_equals("5.mStartAge's not equal", llpsysdata.mStartAge, llpsysdata1.mStartAge, 8);
00200                 ensure_approximately_equals("6.mOuterAngle's not equal", llpsysdata.mOuterAngle, llpsysdata1.mOuterAngle, 5);
00201                 ensure_approximately_equals("7.mInnerAngles's not equal", llpsysdata.mInnerAngle, llpsysdata1.mInnerAngle, 5);
00202                 ensure_approximately_equals("8.mBurstRate's not equal", llpsysdata.mBurstRate, llpsysdata1.mBurstRate, 8);
00203                 ensure("9.mBurstPartCount's not equal", llpsysdata.mBurstPartCount == llpsysdata1.mBurstPartCount);
00204 
00205                 ensure_approximately_equals("10.mBurstSpeedMin's not equal", llpsysdata.mBurstSpeedMin, llpsysdata1.mBurstSpeedMin, 8);
00206                 ensure_approximately_equals("11.mBurstSpeedMax's not equal", llpsysdata.mBurstSpeedMax, llpsysdata1.mBurstSpeedMax, 8);
00207 
00208                 ensure_approximately_equals("12.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[0], llpsysdata1.mAngularVelocity.mV[0], 7);
00209                 ensure_approximately_equals("13.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[1], llpsysdata1.mAngularVelocity.mV[1], 7);
00210                 ensure_approximately_equals("14.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[2], llpsysdata1.mAngularVelocity.mV[2], 7);
00211                         
00212                 ensure_approximately_equals("15.mPartAccel's not equal", llpsysdata.mPartAccel.mV[0], llpsysdata1.mPartAccel.mV[0], 7);
00213                 ensure_approximately_equals("16.mPartAccel's not equal", llpsysdata.mPartAccel.mV[1], llpsysdata1.mPartAccel.mV[1], 7);
00214                 ensure_approximately_equals("17.mPartAccel's not equal", llpsysdata.mPartAccel.mV[2], llpsysdata1.mPartAccel.mV[2], 7);
00215 
00216                 ensure("18.mPartImageID's not equal", llpsysdata.mPartImageID == llpsysdata1.mPartImageID);
00217                 ensure("19.mTargetUUID's not equal", llpsysdata.mTargetUUID == llpsysdata1.mTargetUUID);
00218                 ensure_approximately_equals("20.mBurstRadius's not equal", llpsysdata.mBurstRadius, llpsysdata1.mBurstRadius, 8);
00219         }
00220 }

Generated on Thu Jul 1 06:09:00 2010 for Second Life Viewer by  doxygen 1.4.7