aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCharles Krinke2008-06-05 23:36:59 +0000
committerCharles Krinke2008-06-05 23:36:59 +0000
commit16707b741ea1fd1dacee762ae5573f27f711344e (patch)
treebee1504490ccd942c427b4cd8346e188e283ecdd
parentMantis#1460. Thank you, CMickeyb for a patch that addresses: (diff)
downloadopensim-SC_OLD-16707b741ea1fd1dacee762ae5573f27f711344e.zip
opensim-SC_OLD-16707b741ea1fd1dacee762ae5573f27f711344e.tar.gz
opensim-SC_OLD-16707b741ea1fd1dacee762ae5573f27f711344e.tar.bz2
opensim-SC_OLD-16707b741ea1fd1dacee762ae5573f27f711344e.tar.xz
Mantis#1451. Thank you kindly, mikem for additional
tests for LSL types and strings.
Diffstat (limited to '')
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs579
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs112
-rw-r--r--prebuild.xml21
3 files changed, 712 insertions, 0 deletions
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs
new file mode 100644
index 0000000..a94370e
--- /dev/null
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs
@@ -0,0 +1,579 @@
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 System;
33
34namespace OpenSim.Region.ScriptEngine.Common.Tests
35{
36 [TestFixture]
37 public class LSL_TypesTestLSLFloat
38 {
39 // Used for testing equality of two floats.
40 private double _lowPrecisionTolerance = 0.000001;
41
42 /// <summary>
43 /// Tests constructing a LSLFloat from an integer.
44 /// </summary>
45 [Test]
46 public void TestConstructFromInt()
47 {
48 // The numbers we test for.
49 Dictionary<int, double> numberSet = new Dictionary<int, double>();
50 numberSet.Add(2, 2.0);
51 numberSet.Add(-2, -2.0);
52 numberSet.Add(0, 0.0);
53 numberSet.Add(1, 1.0);
54 numberSet.Add(-1, -1.0);
55 numberSet.Add(999999999, 999999999.0);
56 numberSet.Add(-99999999, -99999999.0);
57
58 LSL_Types.LSLFloat testFloat;
59
60 foreach(KeyValuePair<int, double> number in numberSet)
61 {
62 testFloat = new LSL_Types.LSLFloat(number.Key);
63 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
64 }
65 }
66
67 /// <summary>
68 /// Tests constructing a LSLFloat from a double.
69 /// </summary>
70 [Test]
71 public void TestConstructFromDouble()
72 {
73 // The numbers we test for.
74 Dictionary<double, double> numberSet = new Dictionary<double, double>();
75 numberSet.Add(2.0, 2.0);
76 numberSet.Add(-2.0, -2.0);
77 numberSet.Add(0.0, 0.0);
78 numberSet.Add(1.0, 1.0);
79 numberSet.Add(-1.0, -1.0);
80 numberSet.Add(999999999.0, 999999999.0);
81 numberSet.Add(-99999999.0, -99999999.0);
82 numberSet.Add(0.5, 0.5);
83 numberSet.Add(0.0005, 0.0005);
84 numberSet.Add(0.6805, 0.6805);
85 numberSet.Add(-0.5, -0.5);
86 numberSet.Add(-0.0005, -0.0005);
87 numberSet.Add(-0.6805, -0.6805);
88 numberSet.Add(548.5, 548.5);
89 numberSet.Add(2.0005, 2.0005);
90 numberSet.Add(349485435.6805, 349485435.6805);
91 numberSet.Add(-548.5, -548.5);
92 numberSet.Add(-2.0005, -2.0005);
93 numberSet.Add(-349485435.6805, -349485435.6805);
94
95 LSL_Types.LSLFloat testFloat;
96
97 foreach(KeyValuePair<double, double> number in numberSet)
98 {
99 testFloat = new LSL_Types.LSLFloat(number.Key);
100 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
101 }
102 }
103
104 /// <summary>
105 /// Tests LSLFloat is correctly cast implicitly to integer.
106 /// </summary>
107 [Test]
108 public void TestImplicitCastLSLFloatToInt()
109 {
110 // The numbers we test for.
111 Dictionary<double, int> numberSet = new Dictionary<double, int>();
112 numberSet.Add(2.0, 2);
113 numberSet.Add(-2.0, -2);
114 numberSet.Add(0.0, 0);
115 numberSet.Add(1.0, 1);
116 numberSet.Add(-1.0, -1);
117 numberSet.Add(999999999.0, 999999999);
118 numberSet.Add(-99999999.0, -99999999);
119 numberSet.Add(0.5, 0);
120 numberSet.Add(0.0005, 0);
121 numberSet.Add(0.6805, 0);
122 numberSet.Add(-0.5, 0);
123 numberSet.Add(-0.0005, 0);
124 numberSet.Add(-0.6805, 0);
125 numberSet.Add(548.5, 548);
126 numberSet.Add(2.0005, 2);
127 numberSet.Add(349485435.6805, 349485435);
128 numberSet.Add(-548.5, -548);
129 numberSet.Add(-2.0005, -2);
130 numberSet.Add(-349485435.6805, -349485435);
131
132 int testNumber;
133
134 foreach(KeyValuePair<double, int> number in numberSet)
135 {
136 testNumber = new LSL_Types.LSLFloat(number.Key);
137 Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value);
138 }
139 }
140
141 /// <summary>
142 /// Tests LSLFloat is correctly cast implicitly to unsigned integer.
143 /// </summary>
144 [Test]
145 public void TestImplicitCastLSLFloatToUint()
146 {
147 // The numbers we test for.
148 Dictionary<double, int> numberSet = new Dictionary<double, int>();
149 numberSet.Add(2.0, 2);
150 numberSet.Add(-2.0, 2);
151 numberSet.Add(0.0, 0);
152 numberSet.Add(1.0, 1);
153 numberSet.Add(-1.0, 1);
154 numberSet.Add(999999999.0, 999999999);
155 numberSet.Add(-99999999.0, 99999999);
156 numberSet.Add(0.5, 0);
157 numberSet.Add(0.0005, 0);
158 numberSet.Add(0.6805, 0);
159 numberSet.Add(-0.5, 0);
160 numberSet.Add(-0.0005, 0);
161 numberSet.Add(-0.6805, 0);
162 numberSet.Add(548.5, 548);
163 numberSet.Add(2.0005, 2);
164 numberSet.Add(349485435.6805, 349485435);
165 numberSet.Add(-548.5, 548);
166 numberSet.Add(-2.0005, 2);
167 numberSet.Add(-349485435.6805, 349485435);
168
169 uint testNumber;
170
171 foreach(KeyValuePair<double, int> number in numberSet)
172 {
173 testNumber = new LSL_Types.LSLFloat(number.Key);
174 Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value);
175 }
176 }
177
178 /// <summary>
179 /// Tests LSLFloat is correctly cast implicitly to Boolean if non-zero.
180 /// </summary>
181 [Test]
182 public void TestImplicitCastLSLFloatToBooleanTrue()
183 {
184 // A bunch of numbers to test with.
185 List<double> numberList = new List<double>();
186 numberList.Add(2.0);
187 numberList.Add(-2.0);
188 numberList.Add(1.0);
189 numberList.Add(-1.0);
190 numberList.Add(999999999.0);
191 numberList.Add(-99999999.0);
192 numberList.Add(0.5);
193 numberList.Add(0.0005);
194 numberList.Add(0.6805);
195 numberList.Add(-0.5);
196 numberList.Add(-0.0005);
197 numberList.Add(-0.6805);
198 numberList.Add(548.5);
199 numberList.Add(2.0005);
200 numberList.Add(349485435.6805);
201 numberList.Add(-548.5);
202 numberList.Add(-2.0005);
203 numberList.Add(-349485435.6805);
204
205 LSL_Types.LSLFloat testFloat;
206 bool testBool;
207
208 foreach(double number in numberList)
209 {
210 testFloat = new LSL_Types.LSLFloat(number);
211 testBool = testFloat;
212
213 Assert.IsTrue(testBool);
214 }
215 }
216
217 /// <summary>
218 /// Tests LSLFloat is correctly cast implicitly to Boolean if zero.
219 /// </summary>
220 [Test]
221 public void TestImplicitCastLSLFloatToBooleanFalse()
222 {
223 LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0);
224 bool testBool = testFloat;
225
226 Assert.IsFalse(testBool);
227 }
228
229 /// <summary>
230 /// Tests integer is correctly cast implicitly to LSLFloat.
231 /// </summary>
232 [Test]
233 public void TestImplicitCastIntToLSLFloat()
234 {
235 // A bunch of numbers to test with.
236 List<int> numberList = new List<int>();
237 numberList.Add(2);
238 numberList.Add(-2);
239 numberList.Add(0);
240 numberList.Add(1);
241 numberList.Add(-1);
242 numberList.Add(999999999);
243 numberList.Add(-99999999);
244
245 LSL_Types.LSLFloat testFloat;
246
247 foreach(int number in numberList)
248 {
249 testFloat = number;
250 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
251 }
252 }
253
254 /// <summary>
255 /// Tests string is correctly cast implicitly to LSLFloat.
256 /// </summary>
257 [Test]
258 public void TestImplicitCastStringToLSLFloat()
259 {
260 // A bunch of numbers to test with.
261 Dictionary<string, double> numberSet = new Dictionary<string, double>();
262 numberSet.Add("2", 2.0);
263 numberSet.Add("-2", -2.0);
264 numberSet.Add("1", 1.0);
265 numberSet.Add("-1", -1.0);
266 numberSet.Add("0", 0.0);
267 numberSet.Add("999999999.0", 999999999.0);
268 numberSet.Add("-99999999.0", -99999999.0);
269 numberSet.Add("0.5", 0.5);
270 numberSet.Add("0.0005", 0.0005);
271 numberSet.Add("0.6805", 0.6805);
272 numberSet.Add("-0.5", -0.5);
273 numberSet.Add("-0.0005", -0.0005);
274 numberSet.Add("-0.6805", -0.6805);
275 numberSet.Add("548.5", 548.5);
276 numberSet.Add("2.0005", 2.0005);
277 numberSet.Add("349485435.6805", 349485435.6805);
278 numberSet.Add("-548.5", -548.5);
279 numberSet.Add("-2.0005", -2.0005);
280 numberSet.Add("-349485435.6805", -349485435.6805);
281
282 LSL_Types.LSLFloat testFloat;
283
284 foreach(KeyValuePair<string, double> number in numberSet)
285 {
286 testFloat = number.Key;
287 Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance));
288 }
289 }
290
291 /// <summary>
292 /// Tests double is correctly cast implicitly to LSLFloat.
293 /// </summary>
294 [Test]
295 public void TestImplicitCastDoubleToLSLFloat()
296 {
297 // A bunch of numbers to test with.
298 List<double> numberList = new List<double>();
299 numberList.Add(2.0);
300 numberList.Add(-2.0);
301 numberList.Add(1.0);
302 numberList.Add(-1.0);
303 numberList.Add(0.0);
304 numberList.Add(999999999.0);
305 numberList.Add(-99999999.0);
306 numberList.Add(0.5);
307 numberList.Add(0.0005);
308 numberList.Add(0.6805);
309 numberList.Add(-0.5);
310 numberList.Add(-0.0005);
311 numberList.Add(-0.6805);
312 numberList.Add(548.5);
313 numberList.Add(2.0005);
314 numberList.Add(349485435.6805);
315 numberList.Add(-548.5);
316 numberList.Add(-2.0005);
317 numberList.Add(-349485435.6805);
318
319 LSL_Types.LSLFloat testFloat;
320
321 foreach(double number in numberList)
322 {
323 testFloat = number;
324 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
325 }
326 }
327
328 /// <summary>
329 /// Tests the equality (==) operator.
330 /// </summary>
331 [Test]
332 public void TestEqualsOperator()
333 {
334 // A bunch of numbers to test with.
335 List<double> numberList = new List<double>();
336 numberList.Add(2.0);
337 numberList.Add(-2.0);
338 numberList.Add(1.0);
339 numberList.Add(-1.0);
340 numberList.Add(0.0);
341 numberList.Add(999999999.0);
342 numberList.Add(-99999999.0);
343 numberList.Add(0.5);
344 numberList.Add(0.0005);
345 numberList.Add(0.6805);
346 numberList.Add(-0.5);
347 numberList.Add(-0.0005);
348 numberList.Add(-0.6805);
349 numberList.Add(548.5);
350 numberList.Add(2.0005);
351 numberList.Add(349485435.6805);
352 numberList.Add(-548.5);
353 numberList.Add(-2.0005);
354 numberList.Add(-349485435.6805);
355
356 LSL_Types.LSLFloat testFloatA, testFloatB;
357
358 foreach(double number in numberList)
359 {
360 testFloatA = new LSL_Types.LSLFloat(number);
361 testFloatB = new LSL_Types.LSLFloat(number);
362 Assert.IsTrue(testFloatA == testFloatB);
363
364 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
365 Assert.IsFalse(testFloatA == testFloatB);
366 }
367 }
368
369 /// <summary>
370 /// Tests the inequality (!=) operator.
371 /// </summary>
372 [Test]
373 public void TestNotEqualOperator()
374 {
375 // A bunch of numbers to test with.
376 List<double> numberList = new List<double>();
377 numberList.Add(2.0);
378 numberList.Add(-2.0);
379 numberList.Add(1.0);
380 numberList.Add(-1.0);
381 numberList.Add(0.0);
382 numberList.Add(999999999.0);
383 numberList.Add(-99999999.0);
384 numberList.Add(0.5);
385 numberList.Add(0.0005);
386 numberList.Add(0.6805);
387 numberList.Add(-0.5);
388 numberList.Add(-0.0005);
389 numberList.Add(-0.6805);
390 numberList.Add(548.5);
391 numberList.Add(2.0005);
392 numberList.Add(349485435.6805);
393 numberList.Add(-548.5);
394 numberList.Add(-2.0005);
395 numberList.Add(-349485435.6805);
396
397 LSL_Types.LSLFloat testFloatA, testFloatB;
398
399 foreach(double number in numberList)
400 {
401 testFloatA = new LSL_Types.LSLFloat(number);
402 testFloatB = new LSL_Types.LSLFloat(number + 1.0);
403 Assert.IsTrue(testFloatA != testFloatB);
404
405 testFloatB = new LSL_Types.LSLFloat(number);
406 Assert.IsFalse(testFloatA != testFloatB);
407 }
408 }
409
410 /// <summary>
411 /// Tests the increment operator.
412 /// </summary>
413 [Test]
414 public void TestIncrementOperator()
415 {
416 // A bunch of numbers to test with.
417 List<double> numberList = new List<double>();
418 numberList.Add(2.0);
419 numberList.Add(-2.0);
420 numberList.Add(1.0);
421 numberList.Add(-1.0);
422 numberList.Add(0.0);
423 numberList.Add(999999999.0);
424 numberList.Add(-99999999.0);
425 numberList.Add(0.5);
426 numberList.Add(0.0005);
427 numberList.Add(0.6805);
428 numberList.Add(-0.5);
429 numberList.Add(-0.0005);
430 numberList.Add(-0.6805);
431 numberList.Add(548.5);
432 numberList.Add(2.0005);
433 numberList.Add(349485435.6805);
434 numberList.Add(-548.5);
435 numberList.Add(-2.0005);
436 numberList.Add(-349485435.6805);
437
438 LSL_Types.LSLFloat testFloat;
439 double testNumber;
440
441 foreach(double number in numberList)
442 {
443 testFloat = new LSL_Types.LSLFloat(number);
444
445 testNumber = testFloat++;
446 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
447
448 testNumber = testFloat;
449 Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance));
450
451 testNumber = ++testFloat;
452 Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance));
453 }
454 }
455
456 /// <summary>
457 /// Tests the decrement operator.
458 /// </summary>
459 [Test]
460 public void TestDecrementOperator()
461 {
462 // A bunch of numbers to test with.
463 List<double> numberList = new List<double>();
464 numberList.Add(2.0);
465 numberList.Add(-2.0);
466 numberList.Add(1.0);
467 numberList.Add(-1.0);
468 numberList.Add(0.0);
469 numberList.Add(999999999.0);
470 numberList.Add(-99999999.0);
471 numberList.Add(0.5);
472 numberList.Add(0.0005);
473 numberList.Add(0.6805);
474 numberList.Add(-0.5);
475 numberList.Add(-0.0005);
476 numberList.Add(-0.6805);
477 numberList.Add(548.5);
478 numberList.Add(2.0005);
479 numberList.Add(349485435.6805);
480 numberList.Add(-548.5);
481 numberList.Add(-2.0005);
482 numberList.Add(-349485435.6805);
483
484 LSL_Types.LSLFloat testFloat;
485 double testNumber;
486
487 foreach(double number in numberList)
488 {
489 testFloat = new LSL_Types.LSLFloat(number);
490
491 testNumber = testFloat--;
492 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
493
494 testNumber = testFloat;
495 Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance));
496
497 testNumber = --testFloat;
498 Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance));
499 }
500 }
501
502 /// <summary>
503 /// Tests LSLFloat is correctly cast implicitly to double.
504 /// </summary>
505 [Test]
506 public void TestImplicitCastLSLFloatToDouble()
507 {
508 // A bunch of numbers to test with.
509 List<double> numberList = new List<double>();
510 numberList.Add(2.0);
511 numberList.Add(-2.0);
512 numberList.Add(1.0);
513 numberList.Add(-1.0);
514 numberList.Add(0.0);
515 numberList.Add(999999999.0);
516 numberList.Add(-99999999.0);
517 numberList.Add(0.5);
518 numberList.Add(0.0005);
519 numberList.Add(0.6805);
520 numberList.Add(-0.5);
521 numberList.Add(-0.0005);
522 numberList.Add(-0.6805);
523 numberList.Add(548.5);
524 numberList.Add(2.0005);
525 numberList.Add(349485435.6805);
526 numberList.Add(-548.5);
527 numberList.Add(-2.0005);
528 numberList.Add(-349485435.6805);
529
530 double testNumber;
531 LSL_Types.LSLFloat testFloat;
532
533 foreach(double number in numberList)
534 {
535 testFloat = new LSL_Types.LSLFloat(number);
536 testNumber = testFloat;
537
538 Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
539 }
540 }
541
542 /// <summary>
543 /// Tests LSLFloat.ToString().
544 /// </summary>
545 [Test]
546 public void TestToString()
547 {
548 // A bunch of numbers to test with.
549 Dictionary<double, string> numberSet = new Dictionary<double, string>();
550 numberSet.Add(2.0, "2.000000");
551 numberSet.Add(-2.0, "-2.000000");
552 numberSet.Add(1.0, "1.000000");
553 numberSet.Add(-1.0, "-1.000000");
554 numberSet.Add(0.0, "0.000000");
555 numberSet.Add(999999999.0, "999999999.000000");
556 numberSet.Add(-99999999.0, "-99999999.000000");
557 numberSet.Add(0.5, "0.500000");
558 numberSet.Add(0.0005, "0.000500");
559 numberSet.Add(0.6805, "0.680500");
560 numberSet.Add(-0.5, "-0.500000");
561 numberSet.Add(-0.0005, "-0.000500");
562 numberSet.Add(-0.6805, "-0.680500");
563 numberSet.Add(548.5, "548.500000");
564 numberSet.Add(2.0005, "2.000500");
565 numberSet.Add(349485435.6805, "349485435.680500");
566 numberSet.Add(-548.5, "-548.500000");
567 numberSet.Add(-2.0005, "-2.000500");
568 numberSet.Add(-349485435.6805, "-349485435.680500");
569
570 LSL_Types.LSLFloat testFloat;
571
572 foreach(KeyValuePair<double, string> number in numberSet)
573 {
574 testFloat = new LSL_Types.LSLFloat(number.Key);
575 Assert.AreEqual(number.Value, testFloat.ToString());
576 }
577 }
578 }
579}
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs
new file mode 100644
index 0000000..615c045
--- /dev/null
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs
@@ -0,0 +1,112 @@
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 /// <summary>
39 /// Tests constructing a LSLString from an LSLFloat.
40 /// </summary>
41 [Test]
42 public void TestConstructFromLSLFloat()
43 {
44 // The numbers we test for.
45 Dictionary<double, string> numberSet = new Dictionary<double, string>();
46 numberSet.Add(2, "2.000000");
47 numberSet.Add(-2, "-2.000000");
48 numberSet.Add(0, "0.000000");
49 numberSet.Add(1, "1.000000");
50 numberSet.Add(-1, "-1.000000");
51 numberSet.Add(999999999, "999999999.000000");
52 numberSet.Add(-99999999, "-99999999.000000");
53 numberSet.Add(0.5, "0.500000");
54 numberSet.Add(0.0005, "0.000500");
55 numberSet.Add(0.6805, "0.680500");
56 numberSet.Add(-0.5, "-0.500000");
57 numberSet.Add(-0.0005, "-0.000500");
58 numberSet.Add(-0.6805, "-0.680500");
59 numberSet.Add(548.5, "548.500000");
60 numberSet.Add(2.0005, "2.000500");
61 numberSet.Add(349485435.6805, "349485435.680500");
62 numberSet.Add(-548.5, "-548.500000");
63 numberSet.Add(-2.0005, "-2.000500");
64 numberSet.Add(-349485435.6805, "-349485435.680500");
65
66 LSL_Types.LSLString testString;
67
68 foreach(KeyValuePair<double, string> number in numberSet)
69 {
70 testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key));
71 Assert.AreEqual(number.Value, testString.m_string);
72 }
73 }
74
75 /// <summary>
76 /// Tests constructing a LSLString from an LSLFloat.
77 /// </summary>
78 [Test]
79 public void TestExplicitCastLSLFloatToLSLString()
80 {
81 // The numbers we test for.
82 Dictionary<double, string> numberSet = new Dictionary<double, string>();
83 numberSet.Add(2, "2.000000");
84 numberSet.Add(-2, "-2.000000");
85 numberSet.Add(0, "0.000000");
86 numberSet.Add(1, "1.000000");
87 numberSet.Add(-1, "-1.000000");
88 numberSet.Add(999999999, "999999999.000000");
89 numberSet.Add(-99999999, "-99999999.000000");
90 numberSet.Add(0.5, "0.500000");
91 numberSet.Add(0.0005, "0.000500");
92 numberSet.Add(0.6805, "0.680500");
93 numberSet.Add(-0.5, "-0.500000");
94 numberSet.Add(-0.0005, "-0.000500");
95 numberSet.Add(-0.6805, "-0.680500");
96 numberSet.Add(548.5, "548.500000");
97 numberSet.Add(2.0005, "2.000500");
98 numberSet.Add(349485435.6805, "349485435.680500");
99 numberSet.Add(-548.5, "-548.500000");
100 numberSet.Add(-2.0005, "-2.000500");
101 numberSet.Add(-349485435.6805, "-349485435.680500");
102
103 LSL_Types.LSLString testString;
104
105 foreach(KeyValuePair<double, string> number in numberSet)
106 {
107 testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key);
108 Assert.AreEqual(number.Value, testString.m_string);
109 }
110 }
111 }
112}
diff --git a/prebuild.xml b/prebuild.xml
index 2320a94..09dccc3 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1594,6 +1594,27 @@
1594 </Files> 1594 </Files>
1595 </Project> 1595 </Project>
1596 1596
1597 <Project name="OpenSim.Region.ScriptEngine.Common.Tests" path="OpenSim/Tests/OpenSim/Region/ScriptEngine/Common" type="Library">
1598 <Configuration name="Debug">
1599 <Options>
1600 <OutputPath>../../../../../../bin/</OutputPath>
1601 </Options>
1602 </Configuration>
1603 <Configuration name="Release">
1604 <Options>
1605 <OutputPath>../../../../../../bin/</OutputPath>
1606 </Options>
1607 </Configuration>
1608
1609 <ReferencePath>../../../../../../bin/</ReferencePath>
1610 <Reference name="OpenSim.Region.ScriptEngine.Common"/>
1611 <Reference name="OpenSim.Tests.Common"/>
1612 <Reference name="nunit.framework.dll" />
1613 <Files>
1614 <Match pattern="*.cs" recurse="false"/>
1615 </Files>
1616 </Project>
1617
1597 <Project name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library"> 1618 <Project name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library">
1598 <Configuration name="Debug"> 1619 <Configuration name="Debug">
1599 <Options> 1620 <Options>