aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests
diff options
context:
space:
mode:
authorSean Dague2008-09-08 20:34:45 +0000
committerSean Dague2008-09-08 20:34:45 +0000
commitce0a8d7beffccbaeb6b603a96b7729278c4c9e75 (patch)
treefaccd65637c0dab11b2dd787c8985cd7f2c9452b /OpenSim/Region/ScriptEngine/Shared/Tests
parentFix component order on a quaternion for the sit target. This caused (diff)
downloadopensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.zip
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.gz
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.bz2
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.xz
changes to Test directory structure per opensim-dev conversation
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs603
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs133
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs136
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs261
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs62
5 files changed, 1195 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
new file mode 100644
index 0000000..272d06c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
@@ -0,0 +1,603 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 [TestFixture]
36 public class LSL_TypesTestLSLFloat
37 {
38 // Used for testing equality of two floats.
39 private double _lowPrecisionTolerance = 0.000001;
40
41 private Dictionary<int, double> m_intDoubleSet;
42 private Dictionary<double, double> m_doubleDoubleSet;
43 private Dictionary<double, int> m_doubleIntSet;
44 private Dictionary<double, int> m_doubleUintSet;
45 private Dictionary<string, double> m_stringDoubleSet;
46 private Dictionary<double, string> m_doubleStringSet;
47 private List<int> m_intList;
48 private List<double> m_doubleList;
49
50 /// <summary>
51 /// Sets up dictionaries and arrays used in the tests.
52 /// </summary>
53 [TestFixtureSetUp]
54 public void SetUpDataSets()
55 {
56 m_intDoubleSet = new Dictionary<int, double>();
57 m_intDoubleSet.Add(2, 2.0);
58 m_intDoubleSet.Add(-2, -2.0);
59 m_intDoubleSet.Add(0, 0.0);
60 m_intDoubleSet.Add(1, 1.0);
61 m_intDoubleSet.Add(-1, -1.0);
62 m_intDoubleSet.Add(999999999, 999999999.0);
63 m_intDoubleSet.Add(-99999999, -99999999.0);
64
65 m_doubleDoubleSet = new Dictionary<double, double>();
66 m_doubleDoubleSet.Add(2.0, 2.0);
67 m_doubleDoubleSet.Add(-2.0, -2.0);
68 m_doubleDoubleSet.Add(0.0, 0.0);
69 m_doubleDoubleSet.Add(1.0, 1.0);
70 m_doubleDoubleSet.Add(-1.0, -1.0);
71 m_doubleDoubleSet.Add(999999999.0, 999999999.0);
72 m_doubleDoubleSet.Add(-99999999.0, -99999999.0);
73 m_doubleDoubleSet.Add(0.5, 0.5);
74 m_doubleDoubleSet.Add(0.0005, 0.0005);
75 m_doubleDoubleSet.Add(0.6805, 0.6805);
76 m_doubleDoubleSet.Add(-0.5, -0.5);
77 m_doubleDoubleSet.Add(-0.0005, -0.0005);
78 m_doubleDoubleSet.Add(-0.6805, -0.6805);
79 m_doubleDoubleSet.Add(548.5, 548.5);
80 m_doubleDoubleSet.Add(2.0005, 2.0005);
81 m_doubleDoubleSet.Add(349485435.6805, 349485435.6805);
82 m_doubleDoubleSet.Add(-548.5, -548.5);
83 m_doubleDoubleSet.Add(-2.0005, -2.0005);
84 m_doubleDoubleSet.Add(-349485435.6805, -349485435.6805);
85
86 m_doubleIntSet = new Dictionary<double, int>();
87 m_doubleIntSet.Add(2.0, 2);
88 m_doubleIntSet.Add(-2.0, -2);
89 m_doubleIntSet.Add(0.0, 0);
90 m_doubleIntSet.Add(1.0, 1);
91 m_doubleIntSet.Add(-1.0, -1);
92 m_doubleIntSet.Add(999999999.0, 999999999);
93 m_doubleIntSet.Add(-99999999.0, -99999999);
94 m_doubleIntSet.Add(0.5, 0);
95 m_doubleIntSet.Add(0.0005, 0);
96 m_doubleIntSet.Add(0.6805, 0);
97 m_doubleIntSet.Add(-0.5, 0);
98 m_doubleIntSet.Add(-0.0005, 0);
99 m_doubleIntSet.Add(-0.6805, 0);
100 m_doubleIntSet.Add(548.5, 548);
101 m_doubleIntSet.Add(2.0005, 2);
102 m_doubleIntSet.Add(349485435.6805, 349485435);
103 m_doubleIntSet.Add(-548.5, -548);
104 m_doubleIntSet.Add(-2.0005, -2);
105 m_doubleIntSet.Add(-349485435.6805, -349485435);
106
107 m_doubleUintSet = new Dictionary<double, int>();
108 m_doubleUintSet.Add(2.0, 2);
109 m_doubleUintSet.Add(-2.0, 2);
110 m_doubleUintSet.Add(0.0, 0);
111 m_doubleUintSet.Add(1.0, 1);
112 m_doubleUintSet.Add(-1.0, 1);
113 m_doubleUintSet.Add(999999999.0, 999999999);
114 m_doubleUintSet.Add(-99999999.0, 99999999);
115 m_doubleUintSet.Add(0.5, 0);
116 m_doubleUintSet.Add(0.0005, 0);
117 m_doubleUintSet.Add(0.6805, 0);
118 m_doubleUintSet.Add(-0.5, 0);
119 m_doubleUintSet.Add(-0.0005, 0);
120 m_doubleUintSet.Add(-0.6805, 0);
121 m_doubleUintSet.Add(548.5, 548);
122 m_doubleUintSet.Add(2.0005, 2);
123 m_doubleUintSet.Add(349485435.6805, 349485435);
124 m_doubleUintSet.Add(-548.5, 548);
125 m_doubleUintSet.Add(-2.0005, 2);
126 m_doubleUintSet.Add(-349485435.6805, 349485435);
127
128 m_stringDoubleSet = new Dictionary<string, double>();
129 m_stringDoubleSet.Add("2", 2.0);
130 m_stringDoubleSet.Add("-2", -2.0);
131 m_stringDoubleSet.Add("1", 1.0);
132 m_stringDoubleSet.Add("-1", -1.0);
133 m_stringDoubleSet.Add("0", 0.0);
134 m_stringDoubleSet.Add("999999999.0", 999999999.0);
135 m_stringDoubleSet.Add("-99999999.0", -99999999.0);
136 m_stringDoubleSet.Add("0.5", 0.5);
137 m_stringDoubleSet.Add("0.0005", 0.0005);
138 m_stringDoubleSet.Add("0.6805", 0.6805);
139 m_stringDoubleSet.Add("-0.5", -0.5);
140 m_stringDoubleSet.Add("-0.0005", -0.0005);
141 m_stringDoubleSet.Add("-0.6805", -0.6805);
142 m_stringDoubleSet.Add("548.5", 548.5);
143 m_stringDoubleSet.Add("2.0005", 2.0005);
144 m_stringDoubleSet.Add("349485435.6805", 349485435.6805);
145 m_stringDoubleSet.Add("-548.5", -548.5);
146 m_stringDoubleSet.Add("-2.0005", -2.0005);
147 m_stringDoubleSet.Add("-349485435.6805", -349485435.6805);
148
149 m_doubleStringSet = new Dictionary<double, string>();
150 m_doubleStringSet.Add(2.0, "2.000000");
151 m_doubleStringSet.Add(-2.0, "-2.000000");
152 m_doubleStringSet.Add(1.0, "1.000000");
153 m_doubleStringSet.Add(-1.0, "-1.000000");
154 m_doubleStringSet.Add(0.0, "0.000000");
155 m_doubleStringSet.Add(999999999.0, "999999999.000000");
156 m_doubleStringSet.Add(-99999999.0, "-99999999.000000");
157 m_doubleStringSet.Add(0.5, "0.500000");
158 m_doubleStringSet.Add(0.0005, "0.000500");
159 m_doubleStringSet.Add(0.6805, "0.680500");
160 m_doubleStringSet.Add(-0.5, "-0.500000");
161 m_doubleStringSet.Add(-0.0005, "-0.000500");
162 m_doubleStringSet.Add(-0.6805, "-0.680500");
163 m_doubleStringSet.Add(548.5, "548.500000");
164 m_doubleStringSet.Add(2.0005, "2.000500");
165 m_doubleStringSet.Add(349485435.6805, "349485435.680500");
166 m_doubleStringSet.Add(-548.5, "-548.500000");
167 m_doubleStringSet.Add(-2.0005, "-2.000500");
168 m_doubleStringSet.Add(-349485435.6805, "-349485435.680500");
169
170 m_doubleList = new List<double>();
171 m_doubleList.Add(2.0);
172 m_doubleList.Add(-2.0);
173 m_doubleList.Add(1.0);
174 m_doubleList.Add(-1.0);
175 m_doubleList.Add(999999999.0);
176 m_doubleList.Add(-99999999.0);
177 m_doubleList.Add(0.5);
178 m_doubleList.Add(0.0005);
179 m_doubleList.Add(0.6805);
180 m_doubleList.Add(-0.5);
181 m_doubleList.Add(-0.0005);
182 m_doubleList.Add(-0.6805);
183 m_doubleList.Add(548.5);
184 m_doubleList.Add(2.0005);
185 m_doubleList.Add(349485435.6805);
186 m_doubleList.Add(-548.5);
187 m_doubleList.Add(-2.0005);
188 m_doubleList.Add(-349485435.6805);
189
190 m_intList = new List<int>();
191 m_intList.Add(2);
192 m_intList.Add(-2);
193 m_intList.Add(0);
194 m_intList.Add(1);
195 m_intList.Add(-1);
196 m_intList.Add(999999999);
197 m_intList.Add(-99999999);
198 }
199
200 /// <summary>
201 /// Tests constructing a LSLFloat from an integer.
202 /// </summary>
203 [Test]
204 public void TestConstructFromInt()
205 {
206 LSL_Types.LSLFloat testFloat;
207
208 foreach (KeyValuePair<int, double> number in m_intDoubleSet)
209 {
210 testFloat = new LSL_Types.LSLFloat(number.Key);
211 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
212 }
213 }
214
215 /// <summary>
216 /// Tests constructing a LSLFloat from a double.
217 /// </summary>
218 [Test]
219 public void TestConstructFromDouble()
220 {
221 LSL_Types.LSLFloat testFloat;
222
223 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
224 {
225 testFloat = new LSL_Types.LSLFloat(number.Key);
226 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
227 }
228 }
229
230 /// <summary>
231 /// Tests LSLFloat is correctly cast explicitly to integer.
232 /// </summary>
233 [Test]
234 public void TestExplicitCastLSLFloatToInt()
235 {
236 int testNumber;
237
238 foreach (KeyValuePair<double, int> number in m_doubleIntSet)
239 {
240 testNumber = (int) new LSL_Types.LSLFloat(number.Key);
241 Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
242 }
243 }
244
245 /// <summary>
246 /// Tests LSLFloat is correctly cast explicitly to unsigned integer.
247 /// </summary>
248 [Test]
249 public void TestExplicitCastLSLFloatToUint()
250 {
251 uint testNumber;
252
253 foreach (KeyValuePair<double, int> number in m_doubleUintSet)
254 {
255 testNumber = (uint) new LSL_Types.LSLFloat(number.Key);
256 Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
257 }
258 }
259
260 /// <summary>
261 /// Tests LSLFloat is correctly cast implicitly to Boolean if non-zero.
262 /// </summary>
263 [Test]
264 public void TestImplicitCastLSLFloatToBooleanTrue()
265 {
266 LSL_Types.LSLFloat testFloat;
267 bool testBool;
268
269 foreach (double number in m_doubleList)
270 {
271 testFloat = new LSL_Types.LSLFloat(number);
272 testBool = testFloat;
273
274 Assert.IsTrue(testBool);
275 }
276 }
277
278 /// <summary>
279 /// Tests LSLFloat is correctly cast implicitly to Boolean if zero.
280 /// </summary>
281 [Test]
282 public void TestImplicitCastLSLFloatToBooleanFalse()
283 {
284 LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0);
285 bool testBool = testFloat;
286
287 Assert.IsFalse(testBool);
288 }
289
290 /// <summary>
291 /// Tests integer is correctly cast implicitly to LSLFloat.
292 /// </summary>
293 [Test]
294 public void TestImplicitCastIntToLSLFloat()
295 {
296 LSL_Types.LSLFloat testFloat;
297
298 foreach (int number in m_intList)
299 {
300 testFloat = number;
301 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
302 }
303 }
304
305 /// <summary>
306 /// Tests LSLInteger is correctly cast implicitly to LSLFloat.
307 /// </summary>
308 [Test]
309 public void TestImplicitCastLSLIntegerToLSLFloat()
310 {
311 LSL_Types.LSLFloat testFloat;
312
313 foreach (int number in m_intList)
314 {
315 testFloat = new LSL_Types.LSLInteger(number);
316 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
317 }
318 }
319
320 /// <summary>
321 /// Tests LSLInteger is correctly cast explicitly to LSLFloat.
322 /// </summary>
323 [Test]
324 public void TestExplicitCastLSLIntegerToLSLFloat()
325 {
326 LSL_Types.LSLFloat testFloat;
327
328 foreach (int number in m_intList)
329 {
330 testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLInteger(number);
331 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
332 }
333 }
334
335 /// <summary>
336 /// Tests string is correctly cast explicitly to LSLFloat.
337 /// </summary>
338 [Test]
339 public void TestExplicitCastStringToLSLFloat()
340 {
341 LSL_Types.LSLFloat testFloat;
342
343 foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
344 {
345 testFloat = (LSL_Types.LSLFloat) number.Key;
346 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
347 }
348 }
349
350 /// <summary>
351 /// Tests LSLString is correctly cast implicitly to LSLFloat.
352 /// </summary>
353 [Test]
354 public void TestExplicitCastLSLStringToLSLFloat()
355 {
356 LSL_Types.LSLFloat testFloat;
357
358 foreach (KeyValuePair<string, double> number in m_stringDoubleSet)
359 {
360 testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLString(number.Key);
361 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
362 }
363 }
364
365 /// <summary>
366 /// Tests double is correctly cast implicitly to LSLFloat.
367 /// </summary>
368 [Test]
369 public void TestImplicitCastDoubleToLSLFloat()
370 {
371 LSL_Types.LSLFloat testFloat;
372
373 foreach (double number in m_doubleList)
374 {
375 testFloat = number;
376 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
377 }
378 }
379
380 /// <summary>
381 /// Tests LSLFloat is correctly cast implicitly to double.
382 /// </summary>
383 [Test]
384 public void TestImplicitCastLSLFloatToDouble()
385 {
386 double testNumber;
387 LSL_Types.LSLFloat testFloat;
388
389 foreach (double number in m_doubleList)
390 {
391 testFloat = new LSL_Types.LSLFloat(number);
392 testNumber = testFloat;
393
394 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
395 }
396 }
397
398 /// <summary>
399 /// Tests LSLFloat is correctly cast explicitly to float
400 /// </summary>
401 [Test]
402 public void TestExplicitCastLSLFloatToFloat()
403 {
404 float testFloat;
405 float numberAsFloat;
406 LSL_Types.LSLFloat testLSLFloat;
407 foreach (double number in m_doubleList)
408 {
409 testLSLFloat = new LSL_Types.LSLFloat(number);
410 numberAsFloat = (float)number;
411 testFloat = (float)testLSLFloat;
412
413 Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance));
414 }
415 }
416
417
418 /// <summary>
419 /// Tests the equality (==) operator.
420 /// </summary>
421 [Test]
422 public void TestEqualsOperator()
423 {
424 LSL_Types.LSLFloat testFloatA, testFloatB;
425
426 foreach (double number in m_doubleList)
427 {
428 testFloatA = new LSL_Types.LSLFloat(number);
429 testFloatB = new LSL_Types.LSLFloat(number);
430 Assert.IsTrue(testFloatA == testFloatB);
431
432 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
433 Assert.IsFalse(testFloatA == testFloatB);
434 }
435 }
436
437 /// <summary>
438 /// Tests the inequality (!=) operator.
439 /// </summary>
440 [Test]
441 public void TestNotEqualOperator()
442 {
443 LSL_Types.LSLFloat testFloatA, testFloatB;
444
445 foreach (double number in m_doubleList)
446 {
447 testFloatA = new LSL_Types.LSLFloat(number);
448 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
449 Assert.IsTrue(testFloatA != testFloatB);
450
451 testFloatB = new LSL_Types.LSLFloat(number);
452 Assert.IsFalse(testFloatA != testFloatB);
453 }
454 }
455
456 /// <summary>
457 /// Tests the increment operator.
458 /// </summary>
459 [Test]
460 public void TestIncrementOperator()
461 {
462 LSL_Types.LSLFloat testFloat;
463 double testNumber;
464
465 foreach (double number in m_doubleList)
466 {
467 testFloat = new LSL_Types.LSLFloat(number);
468
469 testNumber = testFloat++;
470 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
471
472 testNumber = testFloat;
473 Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance));
474
475 testNumber = ++testFloat;
476 Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance));
477 }
478 }
479
480 /// <summary>
481 /// Tests the decrement operator.
482 /// </summary>
483 [Test]
484 public void TestDecrementOperator()
485 {
486 LSL_Types.LSLFloat testFloat;
487 double testNumber;
488
489 foreach (double number in m_doubleList)
490 {
491 testFloat = new LSL_Types.LSLFloat(number);
492
493 testNumber = testFloat--;
494 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
495
496 testNumber = testFloat;
497 Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance));
498
499 testNumber = --testFloat;
500 Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance));
501 }
502 }
503
504 /// <summary>
505 /// Tests LSLFloat.ToString().
506 /// </summary>
507 [Test]
508 public void TestToString()
509 {
510 LSL_Types.LSLFloat testFloat;
511
512 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
513 {
514 testFloat = new LSL_Types.LSLFloat(number.Key);
515 Assert.AreEqual(number.Value, testFloat.ToString());
516 }
517 }
518
519 /// <summary>
520 /// Tests addition of two LSLFloats.
521 /// </summary>
522 [Test]
523 public void TestAddTwoLSLFloats()
524 {
525 LSL_Types.LSLFloat testResult;
526
527 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
528 {
529 testResult = new LSL_Types.LSLFloat(number.Key) + new LSL_Types.LSLFloat(number.Value);
530 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key + number.Value, _lowPrecisionTolerance));
531 }
532 }
533
534 /// <summary>
535 /// Tests subtraction of two LSLFloats.
536 /// </summary>
537 [Test]
538 public void TestSubtractTwoLSLFloats()
539 {
540 LSL_Types.LSLFloat testResult;
541
542 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
543 {
544 testResult = new LSL_Types.LSLFloat(number.Key) - new LSL_Types.LSLFloat(number.Value);
545 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key - number.Value, _lowPrecisionTolerance));
546 }
547 }
548
549 /// <summary>
550 /// Tests multiplication of two LSLFloats.
551 /// </summary>
552 [Test]
553 public void TestMultiplyTwoLSLFloats()
554 {
555 LSL_Types.LSLFloat testResult;
556
557 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
558 {
559 testResult = new LSL_Types.LSLFloat(number.Key) * new LSL_Types.LSLFloat(number.Value);
560 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key * number.Value, _lowPrecisionTolerance));
561 }
562 }
563
564 /// <summary>
565 /// Tests division of two LSLFloats.
566 /// </summary>
567 [Test]
568 public void TestDivideTwoLSLFloats()
569 {
570 LSL_Types.LSLFloat testResult;
571
572 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
573 {
574 if (number.Value != 0.0) // Let's avoid divide by zero.
575 {
576 testResult = new LSL_Types.LSLFloat(number.Key) / new LSL_Types.LSLFloat(number.Value);
577 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key / number.Value, _lowPrecisionTolerance));
578 }
579 }
580 }
581
582 /// <summary>
583 /// Tests boolean correctly cast implicitly to LSLFloat.
584 /// </summary>
585 [Test]
586 public void TestImplicitCastBooleanToLSLFloat()
587 {
588 LSL_Types.LSLFloat testFloat;
589
590 testFloat = (1 == 0);
591 Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance));
592
593 testFloat = (1 == 1);
594 Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance));
595
596 testFloat = false;
597 Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance));
598
599 testFloat = true;
600 Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance));
601 }
602 }
603}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
new file mode 100644
index 0000000..f826c00
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
@@ -0,0 +1,133 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 [TestFixture]
36 public class LSL_TypesTestLSLInteger
37 {
38 private Dictionary<double, int> m_doubleIntSet;
39 private Dictionary<string, int> m_stringIntSet;
40
41 /// <summary>
42 /// Sets up dictionaries and arrays used in the tests.
43 /// </summary>
44 [TestFixtureSetUp]
45 public void SetUpDataSets()
46 {
47 m_doubleIntSet = new Dictionary<double, int>();
48 m_doubleIntSet.Add(2.0, 2);
49 m_doubleIntSet.Add(-2.0, -2);
50 m_doubleIntSet.Add(0.0, 0);
51 m_doubleIntSet.Add(1.0, 1);
52 m_doubleIntSet.Add(-1.0, -1);
53 m_doubleIntSet.Add(999999999.0, 999999999);
54 m_doubleIntSet.Add(-99999999.0, -99999999);
55
56 m_stringIntSet = new Dictionary<string, int>();
57 m_stringIntSet.Add("2", 2);
58 m_stringIntSet.Add("-2", -2);
59 m_stringIntSet.Add("0", 0);
60 m_stringIntSet.Add("1", 1);
61 m_stringIntSet.Add("-1", -1);
62 m_stringIntSet.Add("123.9", 123);
63 m_stringIntSet.Add("999999999", 999999999);
64 m_stringIntSet.Add("-99999999", -99999999);
65 }
66
67 /// <summary>
68 /// Tests LSLFloat is correctly cast explicitly to LSLInteger.
69 /// </summary>
70 [Test]
71 public void TestExplicitCastLSLFloatToLSLInteger()
72 {
73 LSL_Types.LSLInteger testInteger;
74
75 foreach (KeyValuePair<double, int> number in m_doubleIntSet)
76 {
77 testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLFloat(number.Key);
78 Assert.AreEqual(testInteger.value, number.Value);
79 }
80 }
81
82 /// <summary>
83 /// Tests string is correctly cast explicitly to LSLInteger.
84 /// </summary>
85 [Test]
86 public void TestExplicitCastStringToLSLInteger()
87 {
88 LSL_Types.LSLInteger testInteger;
89
90 foreach (KeyValuePair<string, int> number in m_stringIntSet)
91 {
92 testInteger = (LSL_Types.LSLInteger) number.Key;
93 Assert.AreEqual(testInteger.value, number.Value);
94 }
95 }
96
97 /// <summary>
98 /// Tests LSLString is correctly cast explicitly to LSLInteger.
99 /// </summary>
100 [Test]
101 public void TestExplicitCastLSLStringToLSLInteger()
102 {
103 LSL_Types.LSLInteger testInteger;
104
105 foreach (KeyValuePair<string, int> number in m_stringIntSet)
106 {
107 testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLString(number.Key);
108 Assert.AreEqual(testInteger.value, number.Value);
109 }
110 }
111
112 /// <summary>
113 /// Tests boolean correctly cast implicitly to LSLInteger.
114 /// </summary>
115 [Test]
116 public void TestImplicitCastBooleanToLSLInteger()
117 {
118 LSL_Types.LSLInteger testInteger;
119
120 testInteger = (1 == 0);
121 Assert.AreEqual(0, testInteger.value);
122
123 testInteger = (1 == 1);
124 Assert.AreEqual(1, testInteger.value);
125
126 testInteger = false;
127 Assert.AreEqual(0, testInteger.value);
128
129 testInteger = true;
130 Assert.AreEqual(1, testInteger.value);
131 }
132 }
133}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
new file mode 100644
index 0000000..49e5023
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
@@ -0,0 +1,136 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 [TestFixture]
36 public class LSL_TypesTestLSLString
37 {
38 private Dictionary<double, string> m_doubleStringSet;
39
40 /// <summary>
41 /// Sets up dictionaries and arrays used in the tests.
42 /// </summary>
43 [TestFixtureSetUp]
44 public void SetUpDataSets()
45 {
46 m_doubleStringSet = new Dictionary<double, string>();
47 m_doubleStringSet.Add(2, "2.000000");
48 m_doubleStringSet.Add(-2, "-2.000000");
49 m_doubleStringSet.Add(0, "0.000000");
50 m_doubleStringSet.Add(1, "1.000000");
51 m_doubleStringSet.Add(-1, "-1.000000");
52 m_doubleStringSet.Add(999999999, "999999999.000000");
53 m_doubleStringSet.Add(-99999999, "-99999999.000000");
54 m_doubleStringSet.Add(0.5, "0.500000");
55 m_doubleStringSet.Add(0.0005, "0.000500");
56 m_doubleStringSet.Add(0.6805, "0.680500");
57 m_doubleStringSet.Add(-0.5, "-0.500000");
58 m_doubleStringSet.Add(-0.0005, "-0.000500");
59 m_doubleStringSet.Add(-0.6805, "-0.680500");
60 m_doubleStringSet.Add(548.5, "548.500000");
61 m_doubleStringSet.Add(2.0005, "2.000500");
62 m_doubleStringSet.Add(349485435.6805, "349485435.680500");
63 m_doubleStringSet.Add(-548.5, "-548.500000");
64 m_doubleStringSet.Add(-2.0005, "-2.000500");
65 m_doubleStringSet.Add(-349485435.6805, "-349485435.680500");
66 }
67
68 /// <summary>
69 /// Tests constructing a LSLString from an LSLFloat.
70 /// </summary>
71 [Test]
72 public void TestConstructFromLSLFloat()
73 {
74 LSL_Types.LSLString testString;
75
76 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
77 {
78 testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key));
79 Assert.AreEqual(number.Value, testString.m_string);
80 }
81 }
82
83 /// <summary>
84 /// Tests constructing a LSLString from an LSLFloat.
85 /// </summary>
86 [Test]
87 public void TestExplicitCastLSLFloatToLSLString()
88 {
89 LSL_Types.LSLString testString;
90
91 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
92 {
93 testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key);
94 Assert.AreEqual(number.Value, testString.m_string);
95 }
96 }
97
98 /// <summary>
99 /// Test constructing a Quaternion from a string.
100 /// </summary>
101 [Test]
102 public void TestExplicitCastLSLStringToQuaternion()
103 {
104 string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>";
105 LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString);
106
107 LSL_Types.Quaternion expectedQuaternion = new LSL_Types.Quaternion(0.0, 0.70711, 0.0, 0.70711);
108 LSL_Types.Quaternion stringQuaternion = (LSL_Types.Quaternion) quaternionString;
109 LSL_Types.Quaternion LSLStringQuaternion = (LSL_Types.Quaternion) quaternionLSLString;
110
111 Assert.AreEqual(expectedQuaternion, stringQuaternion);
112 Assert.AreEqual(expectedQuaternion, LSLStringQuaternion);
113 }
114
115 /// <summary>
116 /// Tests boolean correctly cast explicitly to LSLString.
117 /// </summary>
118 [Test]
119 public void TestImplicitCastBooleanToLSLFloat()
120 {
121 LSL_Types.LSLString testString;
122
123 testString = (LSL_Types.LSLString) (1 == 0);
124 Assert.AreEqual("0", testString.m_string);
125
126 testString = (LSL_Types.LSLString) (1 == 1);
127 Assert.AreEqual("1", testString.m_string);
128
129 testString = (LSL_Types.LSLString) false;
130 Assert.AreEqual("0", testString.m_string);
131
132 testString = (LSL_Types.LSLString) true;
133 Assert.AreEqual("1", testString.m_string);
134 }
135 }
136}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
new file mode 100644
index 0000000..7da28dd
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
@@ -0,0 +1,261 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 /// <summary>
36 /// Tests the LSL_Types.list class.
37 /// </summary>
38 [TestFixture]
39 public class LSL_TypesTestList
40 {
41 /// <summary>
42 /// Tests concatenating a string to a list.
43 /// </summary>
44 [Test]
45 public void TestConcatenateString()
46 {
47 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
48 testList += new LSL_Types.LSLString("addition");
49
50 Assert.AreEqual(4, testList.Length);
51 Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]);
52 Assert.AreEqual(typeof(LSL_Types.LSLString), testList.Data[3].GetType());
53
54 LSL_Types.list secondTestList = testList + new LSL_Types.LSLString("more");
55
56 Assert.AreEqual(5, secondTestList.Length);
57 Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]);
58 Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType());
59 }
60
61 /// <summary>
62 /// Tests concatenating an integer to a list.
63 /// </summary>
64 [Test]
65 public void TestConcatenateInteger()
66 {
67 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
68 testList += new LSL_Types.LSLInteger(20);
69
70 Assert.AreEqual(4, testList.Length);
71 Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]);
72 Assert.AreEqual(typeof(LSL_Types.LSLInteger), testList.Data[3].GetType());
73
74 LSL_Types.list secondTestList = testList + new LSL_Types.LSLInteger(2);
75
76 Assert.AreEqual(5, secondTestList.Length);
77 Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]);
78 Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType());
79 }
80
81 /// <summary>
82 /// Tests concatenating a float to a list.
83 /// </summary>
84 [Test]
85 public void TestConcatenateDouble()
86 {
87 LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
88 testList += new LSL_Types.LSLFloat(2.0f);
89
90 Assert.AreEqual(4, testList.Length);
91 Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]);
92 Assert.AreEqual(typeof(LSL_Types.LSLFloat), testList.Data[3].GetType());
93
94 LSL_Types.list secondTestList = testList + new LSL_Types.LSLFloat(0.04f);
95
96 Assert.AreEqual(5, secondTestList.Length);
97 Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]);
98 Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
99 }
100
101 /// <summary>
102 /// Tests casting LSLInteger item to LSLInteger.
103 /// </summary>
104 [Test]
105 public void TestCastLSLIntegerItemToLSLInteger()
106 {
107 LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123);
108 LSL_Types.list testList = new LSL_Types.list(testValue);
109
110 Assert.AreEqual(testValue, (LSL_Types.LSLInteger)testList.Data[0]);
111 }
112
113 /// <summary>
114 /// Tests casting LSLFloat item to LSLFloat.
115 /// </summary>
116 [Test]
117 public void TestCastLSLFloatItemToLSLFloat()
118 {
119 LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987);
120 LSL_Types.list testList = new LSL_Types.list(testValue);
121
122 Assert.AreEqual(testValue, (LSL_Types.LSLFloat)testList.Data[0]);
123 }
124
125 /// <summary>
126 /// Tests casting LSLString item to LSLString.
127 /// </summary>
128 [Test]
129 public void TestCastLSLStringItemToLSLString()
130 {
131 LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there");
132 LSL_Types.list testList = new LSL_Types.list(testValue);
133
134 Assert.AreEqual(testValue, (LSL_Types.LSLString)testList.Data[0]);
135 }
136
137 /// <summary>
138 /// Tests casting Vector3 item to Vector3.
139 /// </summary>
140 [Test]
141 public void TestCastVector3ItemToVector3()
142 {
143 LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987);
144 LSL_Types.list testList = new LSL_Types.list(testValue);
145
146 Assert.AreEqual(testValue, (LSL_Types.Vector3)testList.Data[0]);
147 }
148 /// <summary>
149 /// Tests casting Quaternion item to Quaternion.
150 /// </summary>
151 [Test]
152 public void TestCastQuaternionItemToQuaternion()
153 {
154 LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987);
155 LSL_Types.list testList = new LSL_Types.list(testValue);
156
157 Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]);
158 }
159
160//====================================================================================
161
162 /// <summary>
163 /// Tests GetLSLIntegerItem for LSLInteger item.
164 /// </summary>
165 [Test]
166 public void TestGetLSLIntegerItemForLSLIntegerItem()
167 {
168 LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911);
169 LSL_Types.list testList = new LSL_Types.list(testValue);
170
171 Assert.AreEqual(testValue, testList.GetLSLIntegerItem(0));
172 }
173
174 /// <summary>
175 /// Tests GetLSLFloatItem for LSLFloat item.
176 /// </summary>
177 [Test]
178 public void TestGetLSLFloatItemForLSLFloatItem()
179 {
180 LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876);
181 LSL_Types.list testList = new LSL_Types.list(testValue);
182
183 Assert.AreEqual(testValue, testList.GetLSLFloatItem(0));
184 }
185
186 /// <summary>
187 /// Tests GetLSLFloatItem for LSLInteger item.
188 /// </summary>
189 [Test]
190 public void TestGetLSLFloatItemForLSLIntegerItem()
191 {
192 LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987);
193 LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue);
194 LSL_Types.list testList = new LSL_Types.list(testValue);
195
196 Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0));
197 }
198
199 /// <summary>
200 /// Tests GetLSLStringItem for LSLString item.
201 /// </summary>
202 [Test]
203 public void TestGetLSLStringItemForLSLStringItem()
204 {
205 LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all");
206 LSL_Types.list testList = new LSL_Types.list(testValue);
207
208 Assert.AreEqual(testValue, testList.GetLSLStringItem(0));
209 }
210
211 /// <summary>
212 /// Tests GetLSLStringItem for key item.
213 /// </summary>
214 [Test]
215 public void TestGetLSLStringItemForKeyItem()
216 {
217 LSL_Types.key testValue
218 = new LSL_Types.key("98000000-0000-2222-3333-100000001000");
219 LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue);
220 LSL_Types.list testList = new LSL_Types.list(testValue);
221
222 Assert.AreEqual(testStringValue, testList.GetLSLStringItem(0));
223 }
224
225 /// <summary>
226 /// Tests GetVector3Item for Vector3 item.
227 /// </summary>
228 [Test]
229 public void TestGetVector3ItemForVector3Item()
230 {
231 LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987);
232 LSL_Types.list testList = new LSL_Types.list(testValue);
233
234 Assert.AreEqual(testValue, testList.GetVector3Item(0));
235 }
236 /// <summary>
237 /// Tests GetQuaternionItem for Quaternion item.
238 /// </summary>
239 [Test]
240 public void TestGetQuaternionItemForQuaternionItem()
241 {
242 LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987);
243 LSL_Types.list testList = new LSL_Types.list(testValue);
244
245 Assert.AreEqual(testValue, testList.GetQuaternionItem(0));
246 }
247
248 /// <summary>
249 /// Tests GetKeyItem for key item.
250 /// </summary>
251 [Test]
252 public void TestGetKeyItemForKeyItem()
253 {
254 LSL_Types.key testValue
255 = new LSL_Types.key("00000000-0000-2222-3333-100000001012");
256 LSL_Types.list testList = new LSL_Types.list(testValue);
257
258 Assert.AreEqual(testValue, testList.GetKeyItem(0));
259 }
260 }
261}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
new file mode 100644
index 0000000..fb2c00c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 [TestFixture]
36 public class LSL_TypesTestVector3
37 {
38 /// <summary>
39 /// Tests for Vector3
40 /// </summary>
41 [Test]
42
43 public void TestDotProduct()
44 {
45 // The numbers we test for.
46 Dictionary<string, double> expectsSet = new Dictionary<string, double>();
47 expectsSet.Add("<1, 2, 3> * <2, 3, 4>", 20.0);
48 expectsSet.Add("<1, 2, 3> * <0, 0, 0>", 0.0);
49
50 double result;
51 string[] parts;
52 string[] delim = { "*" };
53
54 foreach (KeyValuePair<string, double> ex in expectsSet)
55 {
56 parts = ex.Key.Split(delim, System.StringSplitOptions.None);
57 result = new LSL_Types.Vector3(parts[0]) * new LSL_Types.Vector3(parts[1]);
58 Assert.AreEqual(ex.Value, result);
59 }
60 }
61 }
62}