aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Tests')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLFloat.cs583
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLInteger.cs141
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLString.cs136
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestList.cs101
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestVector3.cs69
5 files changed, 0 insertions, 1030 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLFloat.cs
deleted file mode 100644
index d89bb87..0000000
--- a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLFloat.cs
+++ /dev/null
@@ -1,583 +0,0 @@
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.Common;
32
33namespace OpenSim.Region.ScriptEngine.Common.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 the equality (==) operator.
400 /// </summary>
401 [Test]
402 public void TestEqualsOperator()
403 {
404 LSL_Types.LSLFloat testFloatA, testFloatB;
405
406 foreach (double number in m_doubleList)
407 {
408 testFloatA = new LSL_Types.LSLFloat(number);
409 testFloatB = new LSL_Types.LSLFloat(number);
410 Assert.IsTrue(testFloatA == testFloatB);
411
412 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
413 Assert.IsFalse(testFloatA == testFloatB);
414 }
415 }
416
417 /// <summary>
418 /// Tests the inequality (!=) operator.
419 /// </summary>
420 [Test]
421 public void TestNotEqualOperator()
422 {
423 LSL_Types.LSLFloat testFloatA, testFloatB;
424
425 foreach (double number in m_doubleList)
426 {
427 testFloatA = new LSL_Types.LSLFloat(number);
428 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
429 Assert.IsTrue(testFloatA != testFloatB);
430
431 testFloatB = new LSL_Types.LSLFloat(number);
432 Assert.IsFalse(testFloatA != testFloatB);
433 }
434 }
435
436 /// <summary>
437 /// Tests the increment operator.
438 /// </summary>
439 [Test]
440 public void TestIncrementOperator()
441 {
442 LSL_Types.LSLFloat testFloat;
443 double testNumber;
444
445 foreach (double number in m_doubleList)
446 {
447 testFloat = new LSL_Types.LSLFloat(number);
448
449 testNumber = testFloat++;
450 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
451
452 testNumber = testFloat;
453 Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance));
454
455 testNumber = ++testFloat;
456 Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance));
457 }
458 }
459
460 /// <summary>
461 /// Tests the decrement operator.
462 /// </summary>
463 [Test]
464 public void TestDecrementOperator()
465 {
466 LSL_Types.LSLFloat testFloat;
467 double testNumber;
468
469 foreach (double number in m_doubleList)
470 {
471 testFloat = new LSL_Types.LSLFloat(number);
472
473 testNumber = testFloat--;
474 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
475
476 testNumber = testFloat;
477 Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance));
478
479 testNumber = --testFloat;
480 Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance));
481 }
482 }
483
484 /// <summary>
485 /// Tests LSLFloat.ToString().
486 /// </summary>
487 [Test]
488 public void TestToString()
489 {
490 LSL_Types.LSLFloat testFloat;
491
492 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
493 {
494 testFloat = new LSL_Types.LSLFloat(number.Key);
495 Assert.AreEqual(number.Value, testFloat.ToString());
496 }
497 }
498
499 /// <summary>
500 /// Tests addition of two LSLFloats.
501 /// </summary>
502 [Test]
503 public void TestAddTwoLSLFloats()
504 {
505 LSL_Types.LSLFloat testResult;
506
507 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
508 {
509 testResult = new LSL_Types.LSLFloat(number.Key) + new LSL_Types.LSLFloat(number.Value);
510 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key + number.Value, _lowPrecisionTolerance));
511 }
512 }
513
514 /// <summary>
515 /// Tests subtraction of two LSLFloats.
516 /// </summary>
517 [Test]
518 public void TestSubtractTwoLSLFloats()
519 {
520 LSL_Types.LSLFloat testResult;
521
522 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
523 {
524 testResult = new LSL_Types.LSLFloat(number.Key) - new LSL_Types.LSLFloat(number.Value);
525 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key - number.Value, _lowPrecisionTolerance));
526 }
527 }
528
529 /// <summary>
530 /// Tests multiplication of two LSLFloats.
531 /// </summary>
532 [Test]
533 public void TestMultiplyTwoLSLFloats()
534 {
535 LSL_Types.LSLFloat testResult;
536
537 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
538 {
539 testResult = new LSL_Types.LSLFloat(number.Key) * new LSL_Types.LSLFloat(number.Value);
540 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key * number.Value, _lowPrecisionTolerance));
541 }
542 }
543
544 /// <summary>
545 /// Tests division of two LSLFloats.
546 /// </summary>
547 [Test]
548 public void TestDivideTwoLSLFloats()
549 {
550 LSL_Types.LSLFloat testResult;
551
552 foreach (KeyValuePair<double, double> number in m_doubleDoubleSet)
553 {
554 if (number.Value != 0.0) // Let's avoid divide by zero.
555 {
556 testResult = new LSL_Types.LSLFloat(number.Key) / new LSL_Types.LSLFloat(number.Value);
557 Assert.That(testResult.value, new DoubleToleranceConstraint(number.Key / number.Value, _lowPrecisionTolerance));
558 }
559 }
560 }
561
562 /// <summary>
563 /// Tests boolean correctly cast implicitly to LSLFloat.
564 /// </summary>
565 [Test]
566 public void TestImplicitCastBooleanToLSLFloat()
567 {
568 LSL_Types.LSLFloat testFloat;
569
570 testFloat = (1 == 0);
571 Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance));
572
573 testFloat = (1 == 1);
574 Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance));
575
576 testFloat = false;
577 Assert.That(testFloat.value, new DoubleToleranceConstraint(0.0, _lowPrecisionTolerance));
578
579 testFloat = true;
580 Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance));
581 }
582 }
583}
diff --git a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLInteger.cs
deleted file mode 100644
index a769608..0000000
--- a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLInteger.cs
+++ /dev/null
@@ -1,141 +0,0 @@
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.Common;
32
33namespace OpenSim.Region.ScriptEngine.Common.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 m_stringIntSet.Add("", 0);
66 m_stringIntSet.Add("aa", 0);
67 m_stringIntSet.Add("42", 42);
68 m_stringIntSet.Add("42 is the answer", 42);
69 m_stringIntSet.Add(" 42", 42);
70 m_stringIntSet.Add("42,123,456", 42);
71 m_stringIntSet.Add("0xff", 255);
72 m_stringIntSet.Add("12345678900000", -1);
73 }
74
75 /// <summary>
76 /// Tests LSLFloat is correctly cast explicitly to LSLInteger.
77 /// </summary>
78 [Test]
79 public void TestExplicitCastLSLFloatToLSLInteger()
80 {
81 LSL_Types.LSLInteger testInteger;
82
83 foreach (KeyValuePair<double, int> number in m_doubleIntSet)
84 {
85 testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLFloat(number.Key);
86 Assert.AreEqual(testInteger.value, number.Value);
87 }
88 }
89
90 /// <summary>
91 /// Tests string is correctly cast explicitly to LSLInteger.
92 /// </summary>
93 [Test]
94 public void TestExplicitCastStringToLSLInteger()
95 {
96 LSL_Types.LSLInteger testInteger;
97
98 foreach (KeyValuePair<string, int> number in m_stringIntSet)
99 {
100 testInteger = (LSL_Types.LSLInteger) number.Key;
101 Assert.AreEqual(testInteger.value, number.Value);
102 }
103 }
104
105 /// <summary>
106 /// Tests LSLString is correctly cast explicitly to LSLInteger.
107 /// </summary>
108 [Test]
109 public void TestExplicitCastLSLStringToLSLInteger()
110 {
111 LSL_Types.LSLInteger testInteger;
112
113 foreach (KeyValuePair<string, int> number in m_stringIntSet)
114 {
115 testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLString(number.Key);
116 Assert.AreEqual(testInteger.value, number.Value);
117 }
118 }
119
120 /// <summary>
121 /// Tests boolean correctly cast implicitly to LSLInteger.
122 /// </summary>
123 [Test]
124 public void TestImplicitCastBooleanToLSLInteger()
125 {
126 LSL_Types.LSLInteger testInteger;
127
128 testInteger = (1 == 0);
129 Assert.AreEqual(0, testInteger.value);
130
131 testInteger = (1 == 1);
132 Assert.AreEqual(1, testInteger.value);
133
134 testInteger = false;
135 Assert.AreEqual(0, testInteger.value);
136
137 testInteger = true;
138 Assert.AreEqual(1, testInteger.value);
139 }
140 }
141}
diff --git a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLString.cs
deleted file mode 100644
index 3aa52cb..0000000
--- a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestLSLString.cs
+++ /dev/null
@@ -1,136 +0,0 @@
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.Common;
32
33namespace OpenSim.Region.ScriptEngine.Common.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/Common/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestList.cs
deleted file mode 100644
index 500d19a..0000000
--- a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestList.cs
+++ /dev/null
@@ -1,101 +0,0 @@
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.Common;
32
33namespace OpenSim.Region.ScriptEngine.Common.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(1, 'a', "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(1, 'a', "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 double to a list.
83 /// </summary>
84 [Test]
85 public void TestConcatenateDouble()
86 {
87 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
88 testList += new LSL_Types.LSLFloat(2.0);
89
90 Assert.AreEqual(4, testList.Length);
91 Assert.AreEqual(new LSL_Types.LSLFloat(2.0), 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.04);
95
96 Assert.AreEqual(5, secondTestList.Length);
97 Assert.AreEqual(new LSL_Types.LSLFloat(0.04), secondTestList.Data[4]);
98 Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
99 }
100 }
101}
diff --git a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestVector3.cs
deleted file mode 100644
index 0a41f92..0000000
--- a/OpenSim/Region/ScriptEngine/Common/Tests/LSL_TypesTestVector3.cs
+++ /dev/null
@@ -1,69 +0,0 @@
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.Common;
32using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3;
33
34namespace OpenSim.Region.ScriptEngine.Common.Tests
35{
36 [TestFixture]
37 public class LSL_TypesTestVector3
38 {
39 /// <summary>
40 /// Tests for Vector3
41 /// </summary>
42 [Test]
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 vector(parts[0]) * new vector(parts[1]);
58 Assert.AreEqual(ex.Value, result);
59 }
60 }
61
62 [Test]
63 public void TestUnaryMinusOperator()
64 {
65 Assert.AreEqual(new vector(-1, -1, -1), - (new vector(1, 1, 1)));
66 Assert.AreEqual(new vector(0, 0, 0), - (new vector(0, 0, 0)));
67 }
68 }
69}