aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/llpartdata_tut.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:56 -0500
committerJacek Antonelli2008-08-15 23:44:56 -0500
commitc07901e29ed545bbb02e3bddf148fe1104b94e9f (patch)
treef1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/test/llpartdata_tut.cpp
parentSecond Life viewer sources 1.15.0.2 (diff)
downloadmeta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz
Second Life viewer sources 1.15.1.3
Diffstat (limited to 'linden/indra/test/llpartdata_tut.cpp')
-rw-r--r--linden/indra/test/llpartdata_tut.cpp217
1 files changed, 217 insertions, 0 deletions
diff --git a/linden/indra/test/llpartdata_tut.cpp b/linden/indra/test/llpartdata_tut.cpp
new file mode 100644
index 0000000..ce2cedc
--- /dev/null
+++ b/linden/indra/test/llpartdata_tut.cpp
@@ -0,0 +1,217 @@
1/**
2 * @file llpartdata_tut.cpp
3 * @author Adroit
4 * @date March 2007
5 * @brief LLPartData and LLPartSysData test cases.
6 *
7 * Copyright (c) 2007-2007, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 */
30
31#include <tut/tut.h>
32#include "lltut.h"
33#include "linden_common.h"
34#include "lldatapacker.h"
35#include "llpartdata.h"
36#include "v3math.h"
37#include "llsdserialize.h"
38#include "message.h"
39
40namespace tut
41{
42
43 struct partdata_test
44 {
45 };
46 typedef test_group<partdata_test> partdata_test_t;
47 typedef partdata_test_t::object partdata_test_object_t;
48 tut::partdata_test_t tut_partdata_test("partdata_test");
49
50 template<> template<>
51 void partdata_test_object_t::test<1>()
52 {
53 LLPartData llpdata,llpdata1;
54 U8 pkbuf[128];
55
56 llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK |
57 LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK |
58 LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK |
59 LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK);
60
61 llpdata.setMaxAge(29.3f);
62
63 LLVector3 llvec1(1.0f, .5f, .25f);
64 llpdata.setStartColor(llvec1);
65 llpdata.setStartAlpha(.7f);
66
67 LLVector3 llvec2(.2f, .3f, 1.0f);
68 llpdata.setEndColor(llvec2);
69 llpdata.setEndAlpha(1.0f);
70
71 llpdata.setStartScale(3.23f, 4.0f);
72 llpdata.setEndScale(2.4678f, 1.0f);
73
74 LLDataPackerBinaryBuffer dp((U8*)pkbuf, 128);
75 llpdata.pack(dp);
76
77 S32 cur_size = dp.getCurrentSize();
78
79 LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size);
80 llpdata1.unpack(dp1);
81
82 ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags);
83 ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8);
84
85 ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8);
86 ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8);
87 ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8);
88 ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8);
89
90 ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8);
91 ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8);
92 ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8);
93 ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8);
94
95 ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5);
96 ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5);
97
98 ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5);
99 ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5);
100 }
101
102
103 template<> template<>
104 void partdata_test_object_t::test<2>()
105 {
106 LLPartData llpdata,llpdata1;
107
108 llpdata.setFlags(LLPartData::LL_PART_INTERP_COLOR_MASK | LLPartData::LL_PART_INTERP_SCALE_MASK |
109 LLPartData::LL_PART_BOUNCE_MASK | LLPartData::LL_PART_WIND_MASK | LLPartData::LL_PART_FOLLOW_SRC_MASK |
110 LLPartData::LL_PART_FOLLOW_VELOCITY_MASK | LLPartData::LL_PART_TARGET_POS_MASK | LLPartData::LL_PART_TARGET_LINEAR_MASK |
111 LLPartData::LL_PART_EMISSIVE_MASK | LLPartData::LL_PART_BEAM_MASK | LLPartData::LL_PART_DEAD_MASK);
112
113 llpdata.setMaxAge(29.3f);
114
115 LLVector3 llvec1(1.0f, .5f, .25f);
116 llpdata.setStartColor(llvec1);
117 llpdata.setStartAlpha(.7f);
118
119 LLVector3 llvec2(.2f, .3f, 1.0f);
120 llpdata.setEndColor(llvec2);
121 llpdata.setEndAlpha(1.0f);
122
123 llpdata.setStartScale(3.23f, 4.0f);
124 llpdata.setEndScale(2.4678f, 1.0f);
125
126 LLSD llsd = llpdata.asLLSD();
127
128 llpdata1.fromLLSD(llsd);
129
130 ensure("1.mFlags values are different after unpacking", llpdata1.mFlags == llpdata.mFlags);
131 ensure_approximately_equals("2.mMaxAge values are different after unpacking", llpdata1.mMaxAge, llpdata.mMaxAge, 8);
132
133 ensure_approximately_equals("3.mStartColor[0] values are different after unpacking", llpdata1.mStartColor.mV[0], llpdata.mStartColor.mV[0], 8);
134 ensure_approximately_equals("4.mStartColor[1] values are different after unpacking", llpdata1.mStartColor.mV[1], llpdata.mStartColor.mV[1], 8);
135 ensure_approximately_equals("5.mStartColor[2] values are different after unpacking", llpdata1.mStartColor.mV[2], llpdata.mStartColor.mV[2], 8);
136 ensure_approximately_equals("6.mStartColor[3] values are different after unpacking", llpdata1.mStartColor.mV[3], llpdata.mStartColor.mV[3], 8);
137
138 ensure_approximately_equals("7.mEndColor[0] values are different after unpacking", llpdata1.mEndColor.mV[0], llpdata.mEndColor.mV[0], 8);
139 ensure_approximately_equals("8.mEndColor[1] values are different after unpacking", llpdata1.mEndColor.mV[1], llpdata.mEndColor.mV[1], 8);
140 ensure_approximately_equals("9.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[2], llpdata.mEndColor.mV[2], 8);
141 ensure_approximately_equals("10.mEndColor[2] values are different after unpacking", llpdata1.mEndColor.mV[3], llpdata.mEndColor.mV[3], 8);
142
143 ensure_approximately_equals("11.mStartScale[0] values are different after unpacking", llpdata1.mStartScale.mV[0], llpdata.mStartScale.mV[0], 5);
144 ensure_approximately_equals("12.mStartScale[1] values are different after unpacking", llpdata1.mStartScale.mV[1], llpdata.mStartScale.mV[1], 5);
145
146 ensure_approximately_equals("13.mEndScale[0] values are different after unpacking", llpdata1.mEndScale.mV[0], llpdata.mEndScale.mV[0], 5);
147 ensure_approximately_equals("14.mEndScale[1] values are different after unpacking", llpdata1.mEndScale.mV[1], llpdata.mEndScale.mV[1], 5);
148 }
149
150
151//*********llpartsysdata***********
152
153 template<> template<>
154 void partdata_test_object_t::test<3>()
155 {
156 LLPartSysData llpsysdata, llpsysdata1;
157 U8 pkbuf[256];
158 llpsysdata.setBurstSpeedMin(33.33f);
159 ensure("1.mBurstSpeedMin coudnt be set", 33.33f == llpsysdata.mBurstSpeedMin);
160
161 llpsysdata.setBurstSpeedMax(44.44f);
162 ensure("2.mBurstSpeedMax coudnt be set", 44.44f == llpsysdata.mBurstSpeedMax);
163
164 llpsysdata.setBurstRadius(45.55f);
165 ensure("3.mBurstRadius coudnt be set", 45.55f == llpsysdata.mBurstRadius);
166
167 LLVector3 llvec(44.44f, 111.11f, -40.4f);
168 llpsysdata.setPartAccel(llvec);
169
170 llpsysdata.mCRC = 0xFFFFFFFF;
171 llpsysdata.mFlags = 0x20;
172
173 llpsysdata.mPattern = LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE_EMPTY;
174
175 llpsysdata.mMaxAge = 99.99f;
176 llpsysdata.mStartAge = 18.5f;
177 llpsysdata.mInnerAngle = 4.234f;
178 llpsysdata.mOuterAngle = 7.123f;
179 llpsysdata.mBurstRate = 245.53f;
180 llpsysdata.mBurstPartCount = 0xFF;
181 llpsysdata.mAngularVelocity = llvec;
182
183 llpsysdata.mPartImageID.generate();
184 llpsysdata.mTargetUUID.generate();
185
186 LLDataPackerBinaryBuffer dp((U8*)pkbuf, 256);
187 llpsysdata.pack(dp);
188 S32 cur_size = dp.getCurrentSize();
189 LLDataPackerBinaryBuffer dp1((U8*)pkbuf, cur_size);
190 llpsysdata1.unpack(dp1);
191
192 ensure("1.mCRC's not equal", llpsysdata.mCRC == llpsysdata1.mCRC);
193 ensure("2.mFlags's not equal", llpsysdata.mFlags == llpsysdata1.mFlags);
194 ensure("3.mPattern's not equal", llpsysdata.mPattern == llpsysdata1.mPattern);
195 ensure_approximately_equals("4.mMaxAge's not equal", llpsysdata.mMaxAge , llpsysdata1.mMaxAge, 8);
196 ensure_approximately_equals("5.mStartAge's not equal", llpsysdata.mStartAge, llpsysdata1.mStartAge, 8);
197 ensure_approximately_equals("6.mOuterAngle's not equal", llpsysdata.mOuterAngle, llpsysdata1.mOuterAngle, 5);
198 ensure_approximately_equals("7.mInnerAngles's not equal", llpsysdata.mInnerAngle, llpsysdata1.mInnerAngle, 5);
199 ensure_approximately_equals("8.mBurstRate's not equal", llpsysdata.mBurstRate, llpsysdata1.mBurstRate, 8);
200 ensure("9.mBurstPartCount's not equal", llpsysdata.mBurstPartCount == llpsysdata1.mBurstPartCount);
201
202 ensure_approximately_equals("10.mBurstSpeedMin's not equal", llpsysdata.mBurstSpeedMin, llpsysdata1.mBurstSpeedMin, 8);
203 ensure_approximately_equals("11.mBurstSpeedMax's not equal", llpsysdata.mBurstSpeedMax, llpsysdata1.mBurstSpeedMax, 8);
204
205 ensure_approximately_equals("12.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[0], llpsysdata1.mAngularVelocity.mV[0], 7);
206 ensure_approximately_equals("13.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[1], llpsysdata1.mAngularVelocity.mV[1], 7);
207 ensure_approximately_equals("14.mAngularVelocity's not equal", llpsysdata.mAngularVelocity.mV[2], llpsysdata1.mAngularVelocity.mV[2], 7);
208
209 ensure_approximately_equals("15.mPartAccel's not equal", llpsysdata.mPartAccel.mV[0], llpsysdata1.mPartAccel.mV[0], 7);
210 ensure_approximately_equals("16.mPartAccel's not equal", llpsysdata.mPartAccel.mV[1], llpsysdata1.mPartAccel.mV[1], 7);
211 ensure_approximately_equals("17.mPartAccel's not equal", llpsysdata.mPartAccel.mV[2], llpsysdata1.mPartAccel.mV[2], 7);
212
213 ensure("18.mPartImageID's not equal", llpsysdata.mPartImageID == llpsysdata1.mPartImageID);
214 ensure("19.mTargetUUID's not equal", llpsysdata.mTargetUUID == llpsysdata1.mTargetUUID);
215 ensure_approximately_equals("20.mBurstRadius's not equal", llpsysdata.mBurstRadius, llpsysdata1.mBurstRadius, 8);
216 }
217}