diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/test/llnamevalue_tut.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/test/llnamevalue_tut.cpp')
-rw-r--r-- | linden/indra/test/llnamevalue_tut.cpp | 550 |
1 files changed, 51 insertions, 499 deletions
diff --git a/linden/indra/test/llnamevalue_tut.cpp b/linden/indra/test/llnamevalue_tut.cpp index d38913a..f604e84 100644 --- a/linden/indra/test/llnamevalue_tut.cpp +++ b/linden/indra/test/llnamevalue_tut.cpp | |||
@@ -42,133 +42,7 @@ namespace tut | |||
42 | { | 42 | { |
43 | namevalue_test() | 43 | namevalue_test() |
44 | { | 44 | { |
45 | mExpectedNameValueReference.string = NULL; | ||
46 | mExpectedNameValueType = NVT_NULL; | ||
47 | mCallbackCount = 0; | ||
48 | } | 45 | } |
49 | |||
50 | ~namevalue_test() | ||
51 | { | ||
52 | reset(); | ||
53 | }; | ||
54 | |||
55 | void reset() | ||
56 | { | ||
57 | switch(mExpectedNameValueType) | ||
58 | { | ||
59 | case NVT_STRING: | ||
60 | case NVT_ASSET: | ||
61 | delete [] mExpectedNameValueReference.string; | ||
62 | mExpectedNameValueReference.string = NULL; | ||
63 | break; | ||
64 | case NVT_F32: | ||
65 | delete mExpectedNameValueReference.f32; | ||
66 | mExpectedNameValueReference.f32 = NULL; | ||
67 | break; | ||
68 | case NVT_S32: | ||
69 | delete mExpectedNameValueReference.s32; | ||
70 | mExpectedNameValueReference.s32 = NULL; | ||
71 | break; | ||
72 | case NVT_U32: | ||
73 | delete mExpectedNameValueReference.u32; | ||
74 | mExpectedNameValueReference.u32 = NULL; | ||
75 | break; | ||
76 | case NVT_VEC3: | ||
77 | delete mExpectedNameValueReference.vec3; | ||
78 | mExpectedNameValueReference.vec3 = NULL; | ||
79 | break; | ||
80 | case NVT_U64: | ||
81 | delete mExpectedNameValueReference.u64; | ||
82 | mExpectedNameValueReference.u64 = NULL; | ||
83 | default: | ||
84 | break; | ||
85 | } | ||
86 | |||
87 | mExpectedNameValueType = NVT_NULL; | ||
88 | mCallbackCount = 0; | ||
89 | } | ||
90 | |||
91 | void setExpectedResult(ENameValueType type, void* value) | ||
92 | { | ||
93 | reset(); | ||
94 | mExpectedNameValueType = type; | ||
95 | switch(type) | ||
96 | { | ||
97 | case NVT_STRING: | ||
98 | case NVT_ASSET: | ||
99 | mExpectedNameValueReference.string = new char[strlen((const char*) value)+1]; | ||
100 | strcpy(mExpectedNameValueReference.string, (const char*) value); | ||
101 | break; | ||
102 | case NVT_F32: | ||
103 | mExpectedNameValueReference.f32 = new F32(*((F32*) value)); | ||
104 | break; | ||
105 | case NVT_S32: | ||
106 | mExpectedNameValueReference.s32 = new S32(*((S32*) value)); | ||
107 | break; | ||
108 | case NVT_U32: | ||
109 | mExpectedNameValueReference.u32 = new U32(*((U32*) value)); | ||
110 | break; | ||
111 | case NVT_VEC3: | ||
112 | mExpectedNameValueReference.vec3 = new LLVector3(*((LLVector3*) value)); | ||
113 | break; | ||
114 | case NVT_U64: | ||
115 | mExpectedNameValueReference.u64 = new U64(*((U64*) value)); | ||
116 | default: | ||
117 | break; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void verifyChange(LLNameValue* changed) | ||
122 | { | ||
123 | std::string str = ""; | ||
124 | str += "Expected Value of type: "; | ||
125 | str += NameValueTypeStrings[mExpectedNameValueType]; | ||
126 | str += "not equal"; | ||
127 | |||
128 | switch(mExpectedNameValueType) | ||
129 | { | ||
130 | case NVT_STRING: | ||
131 | ensure_memory_matches(str.c_str(), changed->getString(), strlen(changed->getString()), mExpectedNameValueReference.string, strlen(mExpectedNameValueReference.string)); | ||
132 | break; | ||
133 | case NVT_ASSET: | ||
134 | ensure_memory_matches(str.c_str(), changed->getAsset(), strlen(changed->getAsset()), mExpectedNameValueReference.string, strlen(mExpectedNameValueReference.string)); | ||
135 | break; | ||
136 | case NVT_F32: | ||
137 | ensure(str, *(changed->getF32()) == *mExpectedNameValueReference.f32); | ||
138 | break; | ||
139 | case NVT_S32: | ||
140 | ensure(str, *(changed->getS32()) == *mExpectedNameValueReference.s32); | ||
141 | break; | ||
142 | case NVT_U32: | ||
143 | ensure(str, *(changed->getU32()) == *mExpectedNameValueReference.u32); | ||
144 | break; | ||
145 | case NVT_VEC3: | ||
146 | ensure(str, *(changed->getVec3()) == *mExpectedNameValueReference.vec3); | ||
147 | break; | ||
148 | case NVT_U64: | ||
149 | ensure(str, *(changed->getU64()) == *mExpectedNameValueReference.u64); | ||
150 | break; | ||
151 | default: | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | void HandleCallback(LLNameValue* changed) | ||
157 | { | ||
158 | mCallbackCount++; | ||
159 | verifyChange(changed); | ||
160 | ensure("Callback called more than once", mCallbackCount == 1); | ||
161 | } | ||
162 | |||
163 | static void NameValueCallbackFunction(LLNameValue* changed, void** data) | ||
164 | { | ||
165 | namevalue_test* pNameValue = (namevalue_test*)data; | ||
166 | pNameValue->HandleCallback(changed); | ||
167 | } | ||
168 | |||
169 | ENameValueType mExpectedNameValueType; | ||
170 | UNameValueReference mExpectedNameValueReference; | ||
171 | int mCallbackCount; | ||
172 | }; | 46 | }; |
173 | typedef test_group<namevalue_test> namevalue_t; | 47 | typedef test_group<namevalue_test> namevalue_t; |
174 | typedef namevalue_t::object namevalue_object_t; | 48 | typedef namevalue_t::object namevalue_object_t; |
@@ -225,33 +99,33 @@ namespace tut | |||
225 | ensure("3. getS32 failed", *nValue3.getS32() == -43456787); | 99 | ensure("3. getS32 failed", *nValue3.getS32() == -43456787); |
226 | ensure("sendToData or sendToViewer failed", nValue3.sendToData() && !nValue3.sendToViewer()); | 100 | ensure("sendToData or sendToViewer failed", nValue3.sendToData() && !nValue3.sendToViewer()); |
227 | 101 | ||
228 | LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "CB", "SV"); | 102 | LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW", "SV"); |
229 | LLVector3 llvec4(1.0, 2.0, 3.0); | 103 | LLVector3 llvec4(1.0, 2.0, 3.0); |
230 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); | 104 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); |
231 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_CALLBACK); | 105 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); |
232 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM_VIEWER); | 106 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM_VIEWER); |
233 | ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); | 107 | ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); |
234 | ensure("4. sendToData or sendToViewer failed", !nValue4.sendToData() && nValue4.sendToViewer()); | 108 | ensure("4. sendToData or sendToViewer failed", !nValue4.sendToData() && nValue4.sendToViewer()); |
235 | 109 | ||
236 | LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "CALLBACK", "SIM_VIEWER"); | 110 | LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW", "SIM_VIEWER"); |
237 | LLVector3 llvec5(-1.0f, 2.4f, 3); | 111 | LLVector3 llvec5(-1.0f, 2.4f, 3); |
238 | ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); | 112 | ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); |
239 | ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_CALLBACK); | 113 | ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); |
240 | ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM_VIEWER); | 114 | ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM_VIEWER); |
241 | ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); | 115 | ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); |
242 | ensure("5. sendToData or sendToViewer failed", !nValue5.sendToData() && nValue5.sendToViewer()); | 116 | ensure("5. sendToData or sendToViewer failed", !nValue5.sendToData() && nValue5.sendToViewer()); |
243 | 117 | ||
244 | LLNameValue nValue6("SecondLife", "89764323", "U32", "CALLBACK", "DSV"); | 118 | LLNameValue nValue6("SecondLife", "89764323", "U32", "RW", "DSV"); |
245 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); | 119 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); |
246 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_CALLBACK); | 120 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); |
247 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_DATA_SIM_VIEWER); | 121 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_DATA_SIM_VIEWER); |
248 | ensure("6. getU32 failed", *nValue6.getU32() == 89764323); | 122 | ensure("6. getU32 failed", *nValue6.getU32() == 89764323); |
249 | ensure("6. sendToData or sendToViewer failed", nValue6.sendToData() && nValue6.sendToViewer()); | 123 | ensure("6. sendToData or sendToViewer failed", nValue6.sendToData() && nValue6.sendToViewer()); |
250 | 124 | ||
251 | LLNameValue nValue7("SecondLife", "89764323323232", "U64", "CALLBACK", "SIM_SPACE_VIEWER"); | 125 | LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW", "SIM_SPACE_VIEWER"); |
252 | U64 u64_7 = U64L(89764323323232); | 126 | U64 u64_7 = U64L(89764323323232); |
253 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); | 127 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); |
254 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_CALLBACK); | 128 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); |
255 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_DATA_SIM_VIEWER); | 129 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_DATA_SIM_VIEWER); |
256 | ensure("7. getU32 failed", *nValue7.getU64() == u64_7); | 130 | ensure("7. getU32 failed", *nValue7.getU64() == u64_7); |
257 | ensure("7. sendToData or sendToViewer failed", nValue7.sendToData() && nValue7.sendToViewer()); | 131 | ensure("7. sendToData or sendToViewer failed", nValue7.sendToData() && nValue7.sendToViewer()); |
@@ -288,30 +162,30 @@ namespace tut | |||
288 | ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); | 162 | ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); |
289 | ensure("3. getS32 failed", *nValue3.getS32() == -43456787); | 163 | ensure("3. getS32 failed", *nValue3.getS32() == -43456787); |
290 | 164 | ||
291 | LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "CB"); | 165 | LLNameValue nValue4("SecondLife", "<1.0, 2.0, 3.0>", "VEC3", "RW"); |
292 | LLVector3 llvec4(1.0, 2.0, 3.0); | 166 | LLVector3 llvec4(1.0, 2.0, 3.0); |
293 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); | 167 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); |
294 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_CALLBACK); | 168 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); |
295 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); | 169 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); |
296 | ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); | 170 | ensure("4. getVec3 failed", *nValue4.getVec3() == llvec4); |
297 | 171 | ||
298 | LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "CALLBACK"); | 172 | LLNameValue nValue5("SecondLife", "-1.0, 2.4, 3", "VEC3", "RW"); |
299 | LLVector3 llvec5(-1.0f, 2.4f, 3); | 173 | LLVector3 llvec5(-1.0f, 2.4f, 3); |
300 | ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); | 174 | ensure("5. getTypeEnum failed", nValue5.getTypeEnum() == NVT_VEC3); |
301 | ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_CALLBACK); | 175 | ensure("5. getClassEnum failed", nValue5.getClassEnum() == NVC_READ_WRITE); |
302 | ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM); | 176 | ensure("5. getSendtoEnum failed", nValue5.getSendtoEnum() == NVS_SIM); |
303 | ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); | 177 | ensure("5. getVec3 failed", *nValue5.getVec3() == llvec5); |
304 | 178 | ||
305 | LLNameValue nValue6("SecondLife", "89764323", "U32", "CALLBACK"); | 179 | LLNameValue nValue6("SecondLife", "89764323", "U32", "RW"); |
306 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); | 180 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); |
307 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_CALLBACK); | 181 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); |
308 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); | 182 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); |
309 | ensure("6. getU32 failed", *nValue6.getU32() == 89764323); | 183 | ensure("6. getU32 failed", *nValue6.getU32() == 89764323); |
310 | 184 | ||
311 | LLNameValue nValue7("SecondLife", "89764323323232", "U64", "CALLBACK"); | 185 | LLNameValue nValue7("SecondLife", "89764323323232", "U64", "RW"); |
312 | U64 u64_7 = U64L(89764323323232); | 186 | U64 u64_7 = U64L(89764323323232); |
313 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); | 187 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); |
314 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_CALLBACK); | 188 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); |
315 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); | 189 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); |
316 | ensure("7. getU32 failed", *nValue7.getU64() == u64_7); | 190 | ensure("7. getU32 failed", *nValue7.getU64() == u64_7); |
317 | } | 191 | } |
@@ -343,208 +217,118 @@ namespace tut | |||
343 | ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); | 217 | ensure("3. getClassEnum failed", nValue3.getClassEnum() == NVC_READ_ONLY); |
344 | ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); | 218 | ensure("3. getSendtoEnum failed", nValue3.getSendtoEnum() == NVS_SIM); |
345 | 219 | ||
346 | skip_fail("NVC_CALLBACK does not parse."); | 220 | LLNameValue nValue4("SecondLife", "VEC3", "READ_WRITE"); |
347 | |||
348 | LLNameValue nValue4("SecondLife", "VEC3", "CALLBACK"); | ||
349 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); | 221 | ensure("4. getTypeEnum failed", nValue4.getTypeEnum() == NVT_VEC3); |
350 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_CALLBACK); | 222 | ensure("4. getClassEnum failed", nValue4.getClassEnum() == NVC_READ_WRITE); |
351 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); | 223 | ensure("4. getSendtoEnum failed", nValue4.getSendtoEnum() == NVS_SIM); |
352 | 224 | ||
353 | LLNameValue nValue6("SecondLife", "U32", "CALLBACK"); | 225 | LLNameValue nValue6("SecondLife", "U32", "READ_WRITE"); |
354 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); | 226 | ensure("6. getTypeEnum failed", nValue6.getTypeEnum() == NVT_U32); |
355 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_CALLBACK); | 227 | ensure("6. getClassEnum failed", nValue6.getClassEnum() == NVC_READ_WRITE); |
356 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); | 228 | ensure("6. getSendtoEnum failed", nValue6.getSendtoEnum() == NVS_SIM); |
357 | 229 | ||
358 | LLNameValue nValue7("SecondLife", "U64", "CALLBACK"); | 230 | LLNameValue nValue7("SecondLife", "U64", "READ_WRITE"); |
359 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); | 231 | ensure("7. getTypeEnum failed", nValue7.getTypeEnum() == NVT_U64); |
360 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_CALLBACK); | 232 | ensure("7. getClassEnum failed", nValue7.getClassEnum() == NVC_READ_WRITE); |
361 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); | 233 | ensure("7. getSendtoEnum failed", nValue7.getSendtoEnum() == NVS_SIM); |
362 | } | 234 | } |
363 | 235 | ||
364 | template<> template<> | 236 | template<> template<> |
365 | void namevalue_object_t::test<5>() | 237 | void namevalue_object_t::test<5>() |
366 | { | 238 | { |
367 | skip_fail("callback will be called more than once."); | 239 | LLNameValue nValue("SecondLife", "This is a test", "STRING", "RW", "SIM"); |
368 | LLNameValue nValue("SecondLife", "This is a test", "STRING", "CB", "SIM", NameValueCallbackFunction, (void**) this); | ||
369 | 240 | ||
370 | ensure("getString failed", (0 == strcmp(nValue.getString(),"This is a test"))); | 241 | ensure("getString failed", (0 == strcmp(nValue.getString(),"This is a test"))); |
371 | reset(); | ||
372 | |||
373 | setExpectedResult(NVT_STRING, (void*)"New Value"); | ||
374 | nValue.setString("New Value"); | ||
375 | ensure("String nonzero failed", nValue.nonzero() == TRUE); | ||
376 | reset(); | ||
377 | setExpectedResult(NVT_STRING, (void*)""); | ||
378 | nValue.setString(""); | ||
379 | ensure("String nonzero failed", nValue.nonzero() == FALSE); | ||
380 | reset(); | ||
381 | } | 242 | } |
382 | 243 | ||
383 | template<> template<> | 244 | template<> template<> |
384 | void namevalue_object_t::test<6>() | 245 | void namevalue_object_t::test<6>() |
385 | { | 246 | { |
386 | skip_fail("callback will be called more than once."); | 247 | LLNameValue nValue("SecondLife", "This is a test", "ASSET", "RW", "S"); |
387 | LLNameValue nValue("SecondLife", "This is a test", "ASSET", "CALLBACK", "S", NameValueCallbackFunction, (void**) this); | ||
388 | ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); | 248 | ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); |
389 | reset(); | ||
390 | |||
391 | setExpectedResult(NVT_ASSET, (void*)"New Value"); | ||
392 | nValue.setAsset("New Value"); | ||
393 | reset(); | ||
394 | } | 249 | } |
395 | 250 | ||
396 | template<> template<> | 251 | template<> template<> |
397 | void namevalue_object_t::test<7>() | 252 | void namevalue_object_t::test<7>() |
398 | { | 253 | { |
399 | skip_fail("callback will be called more than once."); | 254 | LLNameValue nValue("SecondLife", "555555", "F32", "RW", "SIM"); |
400 | LLNameValue nValue("SecondLife", "555555", "F32", "CB", "SIM", NameValueCallbackFunction, (void**) this); | ||
401 | 255 | ||
402 | ensure("getF32 failed",*nValue.getF32() == 555555.f); | 256 | ensure("getF32 failed",*nValue.getF32() == 555555.f); |
403 | reset(); | ||
404 | |||
405 | F32 fVal = 0.1f; | ||
406 | setExpectedResult(NVT_F32, &fVal); | ||
407 | nValue.setF32(fVal); | ||
408 | |||
409 | fVal = -11111.1f; | ||
410 | setExpectedResult(NVT_F32, &fVal); | ||
411 | nValue.setF32(fVal); | ||
412 | ensure("F32 nonzero failed", nValue.nonzero() == TRUE); | ||
413 | reset(); | ||
414 | |||
415 | fVal = 0.; | ||
416 | setExpectedResult(NVT_F32, &fVal); | ||
417 | nValue.setF32(fVal); | ||
418 | ensure("F32 nonzero failed", nValue.nonzero() == FALSE); | ||
419 | reset(); | ||
420 | } | 257 | } |
421 | 258 | ||
422 | template<> template<> | 259 | template<> template<> |
423 | void namevalue_object_t::test<8>() | 260 | void namevalue_object_t::test<8>() |
424 | { | 261 | { |
425 | skip_fail("callback will be called more than once."); | 262 | LLNameValue nValue("SecondLife", "-5555", "S32", "RW", "SIM"); |
426 | LLNameValue nValue("SecondLife", "-5555", "S32", "CB", "SIM", NameValueCallbackFunction, (void**) this); | ||
427 | 263 | ||
428 | ensure("getS32 failed", *nValue.getS32() == -5555); | 264 | ensure("getS32 failed", *nValue.getS32() == -5555); |
429 | reset(); | ||
430 | 265 | ||
431 | S32 sVal = 0x7FFFFFFF; | 266 | S32 sVal = 0x7FFFFFFF; |
432 | setExpectedResult(NVT_S32, &sVal); | ||
433 | nValue.setS32(sVal); | 267 | nValue.setS32(sVal); |
268 | ensure("getS32 failed", *nValue.getS32() == sVal); | ||
434 | 269 | ||
435 | sVal = -0x7FFFFFFF; | 270 | sVal = -0x7FFFFFFF; |
436 | setExpectedResult(NVT_S32, &sVal); | ||
437 | nValue.setS32(sVal); | 271 | nValue.setS32(sVal); |
438 | ensure("S32 nonzero failed", nValue.nonzero() == TRUE); | 272 | ensure("getS32 failed", *nValue.getS32() == sVal); |
439 | reset(); | ||
440 | 273 | ||
441 | sVal = 0; | 274 | sVal = 0; |
442 | setExpectedResult(NVT_S32, &sVal); | ||
443 | nValue.setS32(sVal); | 275 | nValue.setS32(sVal); |
444 | ensure("S32 nonzero failed", nValue.nonzero() == FALSE); | 276 | ensure("getS32 failed", *nValue.getS32() == sVal); |
445 | reset(); | ||
446 | } | 277 | } |
447 | 278 | ||
448 | template<> template<> | 279 | template<> template<> |
449 | void namevalue_object_t::test<9>() | 280 | void namevalue_object_t::test<9>() |
450 | { | 281 | { |
451 | LLNameValue nValue("SecondLife", "<-3, 2, 1>", "VEC3", "CB", "SIM", NameValueCallbackFunction, (void**) this); | 282 | LLNameValue nValue("SecondLife", "<-3, 2, 1>", "VEC3", "RW", "SIM"); |
452 | LLVector3 vecExpected(-3, 2, 1); | 283 | LLVector3 vecExpected(-3, 2, 1); |
453 | LLVector3 vec; | 284 | LLVector3 vec; |
454 | nValue.getVec3(vec); | 285 | nValue.getVec3(vec); |
455 | ensure("getVec3 failed", vec == vecExpected); | 286 | ensure("getVec3 failed", vec == vecExpected); |
456 | reset(); | ||
457 | |||
458 | vecExpected.setVec(2, -1, 0); | ||
459 | setExpectedResult(NVT_VEC3, &vecExpected); | ||
460 | nValue.setVec3(vecExpected); | ||
461 | ensure("VEC3 nonzero failed", nValue.nonzero() == TRUE); | ||
462 | reset(); | ||
463 | |||
464 | vecExpected.setVec(0, 0, 0); | ||
465 | setExpectedResult(NVT_VEC3, &vecExpected); | ||
466 | nValue.setVec3(vecExpected); | ||
467 | ensure("VEC3 nonzero failed", nValue.nonzero() == FALSE); | ||
468 | reset(); | ||
469 | } | 287 | } |
470 | 288 | ||
471 | template<> template<> | 289 | template<> template<> |
472 | void namevalue_object_t::test<10>() | 290 | void namevalue_object_t::test<10>() |
473 | { | 291 | { |
474 | LLNameValue nValue("SecondLife", "12345678", "U32", "CB", "SIM", NameValueCallbackFunction, (void**) this); | 292 | LLNameValue nValue("SecondLife", "12345678", "U32", "RW", "SIM"); |
475 | 293 | ||
476 | ensure("getU32 failed",*nValue.getU32() == 12345678); | 294 | ensure("getU32 failed",*nValue.getU32() == 12345678); |
477 | 295 | ||
478 | U32 val = 0xFFFFFFFF; | 296 | U32 val = 0xFFFFFFFF; |
479 | setExpectedResult(NVT_U32, &val); | ||
480 | nValue.setU32(val); | 297 | nValue.setU32(val); |
481 | ensure("U32 nonzero failed", nValue.nonzero() == TRUE); | 298 | ensure("U32 max", *nValue.getU32() == val); |
482 | reset(); | ||
483 | 299 | ||
484 | val = 0; | 300 | val = 0; |
485 | setExpectedResult(NVT_U32, &val); | ||
486 | nValue.setU32(val); | 301 | nValue.setU32(val); |
487 | ensure("U32 nonzero failed", nValue.nonzero() == FALSE); | 302 | ensure("U32 min", *nValue.getU32() == val); |
488 | reset(); | ||
489 | } | 303 | } |
490 | 304 | ||
491 | template<> template<> | 305 | template<> template<> |
492 | void namevalue_object_t::test<11>() | 306 | void namevalue_object_t::test<11>() |
493 | { | 307 | { |
494 | skip_fail("incomplete support for U64."); | 308 | //skip_fail("incomplete support for U64."); |
495 | LLNameValue nValue("SecondLife", "44444444444", "U64", "CB", "SIM", NameValueCallbackFunction, (void**) this); | 309 | LLNameValue nValue("SecondLife", "44444444444", "U64", "RW", "SIM"); |
496 | 310 | ||
497 | ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); | 311 | ensure("getU64 failed",*nValue.getU64() == U64L(44444444444)); |
498 | ensure("U64 nonzero failed", nValue.nonzero() == TRUE); | ||
499 | 312 | ||
500 | // there is no LLNameValue::setU64() | 313 | // there is no LLNameValue::setU64() |
501 | } | 314 | } |
502 | 315 | ||
503 | template<> template<> | ||
504 | void namevalue_object_t::test<12>() | ||
505 | { | ||
506 | LLNameValue nValue("SecondLife F32 RW SIM -333.337600"); | ||
507 | F32 val = nValue.magnitude(); | ||
508 | ensure_equals("F32 magnitude failed", val, 333.337600f); | ||
509 | |||
510 | LLNameValue nValue1("SecondLife STRING RW SIM 3300"); | ||
511 | val = nValue1.magnitude(); | ||
512 | ensure_equals("STRING magnitude failed",val,4.0f); | ||
513 | |||
514 | LLNameValue nValue2("SecondLife S32 RW SIM -3300"); | ||
515 | val = nValue2.magnitude(); | ||
516 | ensure_equals("S32 magnitude failed", val, 3300.); | ||
517 | |||
518 | LLNameValue nValue3("SecondLife U32 RW SIM 3300"); | ||
519 | val = nValue3.magnitude(); | ||
520 | ensure_equals("U32 magnitude failed", val, 3300.); | ||
521 | |||
522 | LLNameValue nValue4("SecondLife VEC3 RW SIM <1,2,3>"); | ||
523 | LLVector3 vec(1,2,3); | ||
524 | val = nValue4.magnitude(); | ||
525 | ensure_equals("VEC3 magnitude failed", val, vec.magVec()); | ||
526 | |||
527 | skip_fail("incomplete support for U64."); | ||
528 | LLNameValue nValue5("SecondLife U64 RW SIM 12345"); | ||
529 | val = nValue5.magnitude(); | ||
530 | ensure_equals("U62 magnitude failed", val, 12345); | ||
531 | } | ||
532 | 316 | ||
533 | template<> template<> | 317 | template<> template<> |
534 | void namevalue_object_t::test<13>() | 318 | void namevalue_object_t::test<12>() |
535 | { | 319 | { |
536 | skip_fail("incomplete support for U64."); | 320 | //skip_fail("incomplete support for U64."); |
537 | LLNameValue nValue("SecondLife U64 RW DSV 44444444444"); | 321 | LLNameValue nValue("SecondLife U64 RW DSV 44444444444"); |
538 | std::string ret_str = nValue.printNameValue(); | 322 | std::string ret_str = nValue.printNameValue(); |
539 | 323 | ||
540 | ensure_equals("1:printNameValue failed",ret_str,"SecondLife U64 RW DSV 44444444444"); | 324 | ensure_equals("1:printNameValue failed",ret_str,"SecondLife U64 RW DSV 44444444444"); |
541 | 325 | ||
542 | LLNameValue nValue1(ret_str.c_str()); | 326 | LLNameValue nValue1(ret_str.c_str()); |
543 | ensure_equals("Serialization of printNameValue failed", nValue, nValue1); | 327 | ensure_equals("Serialization of printNameValue failed", *nValue.getU64(), *nValue1.getU64()); |
544 | } | 328 | } |
545 | 329 | ||
546 | template<> template<> | 330 | template<> template<> |
547 | void namevalue_object_t::test<14>() | 331 | void namevalue_object_t::test<13>() |
548 | { | 332 | { |
549 | LLNameValue nValue("SecondLife STRING RW DSV 44444444444"); | 333 | LLNameValue nValue("SecondLife STRING RW DSV 44444444444"); |
550 | std::string ret_str = nValue.printData(); | 334 | std::string ret_str = nValue.printData(); |
@@ -556,7 +340,7 @@ namespace tut | |||
556 | } | 340 | } |
557 | 341 | ||
558 | template<> template<> | 342 | template<> template<> |
559 | void namevalue_object_t::test<15>() | 343 | void namevalue_object_t::test<14>() |
560 | { | 344 | { |
561 | LLNameValue nValue("SecodLife STRING RW SIM 22222"); | 345 | LLNameValue nValue("SecodLife STRING RW SIM 22222"); |
562 | std::ostringstream stream1,stream2,stream3, stream4, stream5; | 346 | std::ostringstream stream1,stream2,stream3, stream4, stream5; |
@@ -575,271 +359,39 @@ namespace tut | |||
575 | stream4<< nValue3; | 359 | stream4<< nValue3; |
576 | ensure_equals("U32 << failed",stream4.str(),"122222"); | 360 | ensure_equals("U32 << failed",stream4.str(),"122222"); |
577 | 361 | ||
578 | skip_fail("incomplete support for U64."); | 362 | // I don't think we use U64 name value pairs. JC |
579 | LLNameValue nValue4("SecodLife U64 RW SIM 22222"); | 363 | //skip_fail("incomplete support for U64."); |
580 | stream5<< nValue4; | 364 | //LLNameValue nValue4("SecodLife U64 RW SIM 22222"); |
581 | ensure("U64 << failed",0 == strcmp((stream5.str()).c_str(),"22222")); | 365 | //stream5<< nValue4; |
582 | } | 366 | //ensure("U64 << failed",0 == strcmp((stream5.str()).c_str(),"22222")); |
583 | |||
584 | template<> template<> | ||
585 | void namevalue_object_t::test<16>() | ||
586 | { | ||
587 | LLNameValue nValue1("SecondLife STRING RW DSV 44444"); | ||
588 | LLNameValue nValue2("SecondLife STRING RW SIM 33333"); | ||
589 | LLNameValue nValue3("SecondLife"); | ||
590 | nValue3 = nValue1 + nValue2; | ||
591 | ensure("1:operator+ failed",(0==strcmp(nValue3.getString(),"4444433333"))); | ||
592 | |||
593 | LLNameValue nValue4("SecondLife F32 R DSV 44444"); | ||
594 | LLNameValue nValue5("SecondLife F32 RW SIM 33333"); | ||
595 | LLNameValue nValue6("SecondLife"); | ||
596 | nValue6 = nValue4 + nValue5; | ||
597 | ensure_equals("2:operator+ failed",*nValue6.getF32(),77777.0); | ||
598 | |||
599 | LLNameValue nValue7("SecondLife F32 R DSV 44444"); | ||
600 | LLNameValue nValue8("SecondLife S32 RW SIM 33333"); | ||
601 | LLNameValue nValue9("SecondLife F32"); | ||
602 | nValue9 = nValue7 + nValue8; | ||
603 | ensure_equals("3:operator+ failed",*nValue9.getF32(),77777.0); | ||
604 | |||
605 | LLNameValue nValue10("SecondLife VEC3 RW SIM <4, 4, 4>"); | ||
606 | LLNameValue nValue11("SecondLife VEC3 RW SV <3, 3, 3>"); | ||
607 | LLNameValue nValue12("SecondLife VEC3"); | ||
608 | nValue12 = nValue10 + nValue11; | ||
609 | LLVector3 vec(7,7,7); | ||
610 | ensure_equals("4:operator+ failed",*nValue12.getVec3(), vec); | ||
611 | } | ||
612 | |||
613 | template<> template<> | ||
614 | void namevalue_object_t::test<17>() | ||
615 | { | ||
616 | LLNameValue nValue7(" SecondLife S32 RW SIM 22222"); | ||
617 | LLNameValue nValue8(" SecondLife F32 RW SIM 33333"); | ||
618 | LLNameValue nValue9(" SecondLife F32"); | ||
619 | nValue9 = nValue7 - nValue8; | ||
620 | ensure_equals("1:operator- failed",*nValue9.getF32(),-11111.f); | ||
621 | |||
622 | LLNameValue nValue10(" SecondLife VEC3 RW SIM <2, 2, 2>"); | ||
623 | LLNameValue nValue11(" SecondLife VEC3 RW SIM <3, 3, 3>"); | ||
624 | LLNameValue nValue12(" SecondLife VEC3"); | ||
625 | LLVector3 vec(-1,-1,-1); | ||
626 | nValue12 = nValue10 - nValue11; | ||
627 | ensure_equals("2:operator- failed",*nValue12.getVec3(), vec); | ||
628 | } | ||
629 | |||
630 | template<> template<> | ||
631 | void namevalue_object_t::test<18>() | ||
632 | { | ||
633 | |||
634 | LLNameValue nValue1(" SecondLife F32 RW SIM 22222"); | ||
635 | LLNameValue nValue2(" SecondLife F32 RW SIM 33333"); | ||
636 | LLNameValue nValue3(" SecondLife F32"); | ||
637 | nValue3 = nValue1 * nValue2; | ||
638 | ensure_equals("1:operator* failed",*nValue3.getF32(),740725926.f); | ||
639 | |||
640 | LLNameValue nValue4(" SecondLife S32 RW SIM 22222"); | ||
641 | LLNameValue nValue5(" SecondLife F32 RW SIM 33333"); | ||
642 | LLNameValue nValue6(" SecondLife F32"); | ||
643 | nValue6 = nValue4 * nValue5; | ||
644 | ensure_equals("2:operator* failed",*nValue6.getF32(),740725926.f); | ||
645 | |||
646 | LLNameValue nValue10(" SecondLife VEC3 RW SIM <2, 2, 2>"); | ||
647 | LLNameValue nValue11(" SecondLife VEC3 RW SIM <3, 3, 3>"); | ||
648 | LLNameValue nValue12(" SecondLife F32"); | ||
649 | LLVector3 vec1(2,2,2); | ||
650 | LLVector3 vec2(3,3,3); | ||
651 | nValue12 = nValue10 * nValue11; | ||
652 | ensure_equals("2:operator* failed",*nValue12.getF32(), (vec1 * vec2)); | ||
653 | } | 367 | } |
654 | 368 | ||
655 | template<> template<> | 369 | template<> template<> |
656 | void namevalue_object_t::test<19>() | 370 | void namevalue_object_t::test<15>() |
657 | { | ||
658 | LLNameValue nValue1(" SecondLife S32 RW SIM 22222"); | ||
659 | LLNameValue nValue2(" Virtual F32 RW SIM 44444"); | ||
660 | LLNameValue nValue3(" SecondLife F32"); | ||
661 | nValue3 = nValue1 / nValue2; | ||
662 | ensure_equals("1:operator/ failed",*nValue3.getF32(),0.5); | ||
663 | |||
664 | LLNameValue nValue4(" SecondLife F32 RW SIM 33333"); | ||
665 | LLNameValue nValue5(" SecondLife S32 RW SIM 22222"); | ||
666 | LLNameValue nValue6(" SecondLife F32"); | ||
667 | nValue6 = nValue4 / nValue5; | ||
668 | ensure_equals("2:operator/ failed",*nValue6.getF32(),1.5); | ||
669 | } | ||
670 | |||
671 | template<> template<> | ||
672 | void namevalue_object_t::test<20>() | ||
673 | { | ||
674 | LLNameValue nValue1(" SecondLife S32 RW SIM 22222"); | ||
675 | LLNameValue nValue2(" Virtual S32 RW SIM 33333"); | ||
676 | LLNameValue nValue3(" SecondLife S32"); | ||
677 | nValue3 = nValue1 % nValue2; | ||
678 | ensure_equals("1:operator% failed",*nValue3.getS32(),22222); | ||
679 | |||
680 | LLNameValue nValue4(" SecondLife U32 RW SIM 3"); | ||
681 | LLNameValue nValue5(" SecondLife S32 RW SIM 2"); | ||
682 | LLNameValue nValue6(" SecondLife S32"); | ||
683 | nValue6 = nValue4 % nValue5; | ||
684 | ensure_equals("2:operator% failed",*nValue6.getS32(),1); | ||
685 | |||
686 | LLNameValue nValue10(" SecondLife VEC3 RW SIM <4, 5, 6>"); | ||
687 | LLNameValue nValue11(" SecondLife VEC3 RW SIM <1, 2, 3>"); | ||
688 | LLNameValue nValue12(" SecondLife VEC3"); | ||
689 | LLVector3 vec1(4,5,6); | ||
690 | LLVector3 vec2(1,2,3); | ||
691 | LLVector3 vec3(vec1 % vec2); | ||
692 | nValue12 = nValue10 % nValue11; | ||
693 | ensure_equals("5:operator% failed",*nValue12.getVec3(), vec3); | ||
694 | } | ||
695 | |||
696 | template<> template<> | ||
697 | void namevalue_object_t::test<21>() | ||
698 | { | ||
699 | LLNameValue nValue1(" SecondLife STRING RW SIM 22222"); | ||
700 | LLNameValue nValue2(" Virtual STRING RW SIM 22222"); | ||
701 | ensure("1:operator== failed", nValue1 == nValue2); | ||
702 | |||
703 | LLNameValue nValue3(" SecondLife F32 RW SIM 33333"); | ||
704 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
705 | ensure("2:operator== failed",!(nValue3 == nValue4)); | ||
706 | |||
707 | LLNameValue nValue5(" SecondLife STRING RW SIM 22222"); | ||
708 | LLNameValue nValue6(" Virtual STRING RW SIM 33333"); | ||
709 | ensure("3:operator== failed",!(nValue5 == nValue6)); | ||
710 | |||
711 | LLNameValue nValue7(" SecondLife VEC3 RW SIM <2, 2, 2>"); | ||
712 | LLNameValue nValue8(" Virtual VEC3 RW SIM <2, 2, 2>"); | ||
713 | ensure("4:operator== failed",(nValue7 == nValue8)); | ||
714 | } | ||
715 | |||
716 | template<> template<> | ||
717 | void namevalue_object_t::test<22>() | ||
718 | { | ||
719 | LLNameValue nValue1(" SecondLife STRING RW SIM 22222"); | ||
720 | LLNameValue nValue2(" Virtual STRING RW SIM 33333"); | ||
721 | bool b_ret = (nValue1 <= nValue2) ? 1 : 0; | ||
722 | ensure("1:operator<= failed",(1==b_ret)); | ||
723 | |||
724 | LLNameValue nValue3(" SecondLife F32 RW SIM 33333"); | ||
725 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
726 | b_ret = (nValue3 <= nValue4) ? 1 : 0; | ||
727 | ensure("2:operator<= failed",(0==b_ret)); | ||
728 | } | ||
729 | |||
730 | template<> template<> | ||
731 | void namevalue_object_t::test<23>() | ||
732 | { | ||
733 | LLNameValue nValue1(" SecondLife STRING RW SIM 22222"); | ||
734 | LLNameValue nValue2(" Virtual STRING RW SIM 33333"); | ||
735 | bool b_ret = (nValue1 >= nValue2) ? 1 : 0; | ||
736 | ensure("operator>= failed",!b_ret); | ||
737 | |||
738 | LLNameValue nValue3(" SecondLife F32 RW SIM 33333"); | ||
739 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
740 | b_ret = (nValue3 >= nValue4) ? 1 : 0; | ||
741 | ensure("2:operator<= failed",b_ret); | ||
742 | |||
743 | } | ||
744 | |||
745 | template<> template<> | ||
746 | void namevalue_object_t::test<24>() | ||
747 | { | ||
748 | LLNameValue nValue1(" SecondLife STRING RW SIM 33333"); | ||
749 | LLNameValue nValue2(" Virtual STRING RW SIM 33333"); | ||
750 | bool b_ret = (nValue1 < nValue2) ? 1 : 0; | ||
751 | ensure("operator< failed",!b_ret); | ||
752 | |||
753 | LLNameValue nValue3(" SecondLife F32 RW SIM 11111"); | ||
754 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
755 | b_ret = (nValue3 < nValue4) ? 1 : 0; | ||
756 | ensure("2:operator< failed",b_ret); | ||
757 | |||
758 | } | ||
759 | |||
760 | template<> template<> | ||
761 | void namevalue_object_t::test<25>() | ||
762 | { | ||
763 | LLNameValue nValue1(" SecondLife STRING RW SIM 33333"); | ||
764 | LLNameValue nValue2(" Virtual STRING RW SIM 33333"); | ||
765 | bool b_ret = (nValue1 > nValue2) ? 1 : 0; | ||
766 | ensure("1:operator> failed",!b_ret); | ||
767 | |||
768 | LLNameValue nValue3(" SecondLife F32 RW SIM 11111"); | ||
769 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
770 | b_ret = (nValue3 > nValue4) ? 1 : 0; | ||
771 | ensure("2:operator> failed",!b_ret); | ||
772 | |||
773 | LLNameValue nValue5(" SecondLife S32 RW SIM 22222"); | ||
774 | LLNameValue nValue6(" Virtual F32 RW SIM 11111"); | ||
775 | b_ret = (nValue5 > nValue6) ? 1 : 0; | ||
776 | ensure("3:operator> failed",b_ret); | ||
777 | } | ||
778 | |||
779 | template<> template<> | ||
780 | void namevalue_object_t::test<26>() | ||
781 | { | ||
782 | LLNameValue nValue1(" SecondLife STRING RW SIM 33333"); | ||
783 | LLNameValue nValue2(" Virtual STRING RW SIM 33333"); | ||
784 | bool b_ret = (nValue1 != nValue2) ? 1 : 0; | ||
785 | ensure("1:operator!= failed",!b_ret); | ||
786 | |||
787 | LLNameValue nValue3(" SecondLife F32 RW SIM 11111"); | ||
788 | LLNameValue nValue4(" Virtual F32 RW SIM 22222"); | ||
789 | b_ret = (nValue3 != nValue4) ? 1 : 0; | ||
790 | ensure("2:operator!= failed",b_ret); | ||
791 | |||
792 | } | ||
793 | |||
794 | |||
795 | template<> template<> | ||
796 | void namevalue_object_t::test<27>() | ||
797 | { | ||
798 | LLNameValue nValue1(" SecondLife F32 RW SIM 33333"); | ||
799 | LLNameValue nValue2("Virtual"); | ||
800 | nValue2 = -nValue1; | ||
801 | ensure_equals("1:operator unary- failed",*nValue2.getF32(), -33333.f); | ||
802 | |||
803 | LLNameValue nValue3(" SecondLife U32 RW SIM 11111"); | ||
804 | LLNameValue nValue4("Virtual S32"); | ||
805 | nValue4 = -nValue3; | ||
806 | ensure_equals("2:operator unary- failed",*nValue4.getS32(), -11111); | ||
807 | |||
808 | LLNameValue nValue5(" SecondLife VEC3 RW SIM <1, 1, 1>"); | ||
809 | LLNameValue nValue6("Virtual VEC3"); | ||
810 | LLVector3 vec(-1, -1, -1); | ||
811 | nValue6 = -nValue5; | ||
812 | ensure_equals("3:operator unary- failed",*nValue6.getVec3(), vec); | ||
813 | } | ||
814 | |||
815 | template<> template<> | ||
816 | void namevalue_object_t::test<28>() | ||
817 | { | 371 | { |
818 | LLNameValue nValue("SecondLife", "This is a test", "ASSET", "R", "S", NameValueCallbackFunction, (void**) this); | 372 | LLNameValue nValue("SecondLife", "This is a test", "ASSET", "R", "S"); |
819 | 373 | ||
820 | ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); | 374 | ensure("getAsset failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); |
821 | // this should not have updated as it is read only. | 375 | // this should not have updated as it is read only. |
822 | nValue.setAsset("New Value should not be updated"); | 376 | nValue.setAsset("New Value should not be updated"); |
823 | ensure("setAsset on ReadOnly failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); | 377 | ensure("setAsset on ReadOnly failed", (0 == strcmp(nValue.getAsset(),"This is a test"))); |
824 | 378 | ||
825 | LLNameValue nValue1("SecondLife", "1234", "U32", "R", "S", NameValueCallbackFunction, (void**) this); | 379 | LLNameValue nValue1("SecondLife", "1234", "U32", "R", "S"); |
826 | // this should not have updated as it is read only. | 380 | // this should not have updated as it is read only. |
827 | nValue1.setU32(4567); | 381 | nValue1.setU32(4567); |
828 | ensure("setU32 on ReadOnly failed", *nValue1.getU32() == 1234); | 382 | ensure("setU32 on ReadOnly failed", *nValue1.getU32() == 1234); |
829 | 383 | ||
830 | LLNameValue nValue2("SecondLife", "1234", "S32", "R", "S", NameValueCallbackFunction, (void**) this); | 384 | LLNameValue nValue2("SecondLife", "1234", "S32", "R", "S"); |
831 | // this should not have updated as it is read only. | 385 | // this should not have updated as it is read only. |
832 | nValue2.setS32(4567); | 386 | nValue2.setS32(4567); |
833 | ensure("setS32 on ReadOnly failed", *nValue2.getS32() == 1234); | 387 | ensure("setS32 on ReadOnly failed", *nValue2.getS32() == 1234); |
834 | 388 | ||
835 | LLNameValue nValue3("SecondLife", "1234", "F32", "R", "S", NameValueCallbackFunction, (void**) this); | 389 | LLNameValue nValue3("SecondLife", "1234", "F32", "R", "S"); |
836 | // this should not have updated as it is read only. | 390 | // this should not have updated as it is read only. |
837 | nValue3.setF32(4567); | 391 | nValue3.setF32(4567); |
838 | ensure("setF32 on ReadOnly failed", *nValue3.getF32() == 1234); | 392 | ensure("setF32 on ReadOnly failed", *nValue3.getF32() == 1234); |
839 | nValue3 = nValue3 * 2; | ||
840 | ensure("setF32 on ReadOnly failed", *nValue3.getF32() == 1234); | ||
841 | 393 | ||
842 | LLNameValue nValue4("SecondLife", "<1,2,3>", "VEC3", "R", "S", NameValueCallbackFunction, (void**) this); | 394 | LLNameValue nValue4("SecondLife", "<1,2,3>", "VEC3", "R", "S"); |
843 | // this should not have updated as it is read only. | 395 | // this should not have updated as it is read only. |
844 | LLVector3 vec(4,5,6); | 396 | LLVector3 vec(4,5,6); |
845 | nValue3.setVec3(vec); | 397 | nValue3.setVec3(vec); |