From ef27c8817fb2899b02116296001770005622f375 Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Wed, 3 Sep 2008 18:57:06 +0000
Subject: Mantis #2112 Thannk you, ralphos, for a patch to clean up list item
type handling and add a missing explicit cast in Shared/
---
.../ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs | 20 ++++++
.../ScriptEngine/Shared/LSL_TypesTestList.cs | 79 +++++++++++++++++++---
2 files changed, 90 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Tests')
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
index c021963..272d06c 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs
@@ -396,6 +396,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
}
///
+ /// Tests LSLFloat is correctly cast explicitly to float
+ ///
+ [Test]
+ public void TestExplicitCastLSLFloatToFloat()
+ {
+ float testFloat;
+ float numberAsFloat;
+ LSL_Types.LSLFloat testLSLFloat;
+ foreach (double number in m_doubleList)
+ {
+ testLSLFloat = new LSL_Types.LSLFloat(number);
+ numberAsFloat = (float)number;
+ testFloat = (float)testLSLFloat;
+
+ Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance));
+ }
+ }
+
+
+ ///
/// Tests the equality (==) operator.
///
[Test]
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestList.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
index c1c9ef7..9e8d716 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestList.cs
@@ -84,18 +84,79 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
[Test]
public void TestConcatenateDouble()
{
- LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
- testList += 2.0;
+ LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
+ testList += 2.0;
- Assert.AreEqual(4, testList.Length);
- Assert.AreEqual(2.0, testList.Data[3]);
- Assert.AreEqual(typeof(double), testList.Data[3].GetType());
+ Assert.AreEqual(4, testList.Length);
+ Assert.AreEqual(2.0, testList.Data[3]);
+ Assert.AreEqual(typeof(double), testList.Data[3].GetType());
- LSL_Types.list secondTestList = testList + 0.04;
+ LSL_Types.list secondTestList = testList + 0.04;
- Assert.AreEqual(5, secondTestList.Length);
- Assert.AreEqual(0.04, secondTestList.Data[4]);
- Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType());
+ Assert.AreEqual(5, secondTestList.Length);
+ Assert.AreEqual(0.04, secondTestList.Data[4]);
+ Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType());
+ }
+
+ ///
+ /// Tests casting LSLInteger item to LSLInteger.
+ ///
+ [Test]
+ public void TestCastLSLIntegerItemToLSLInteger()
+ {
+ LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123);
+ LSL_Types.list testList = new LSL_Types.list(testValue);
+
+ Assert.AreEqual(testValue, (LSL_Types.LSLInteger)testList.Data[0]);
}
+
+ ///
+ /// Tests casting LSLFloat item to LSLFloat.
+ ///
+ [Test]
+ public void TestCastLSLFloatItemToLSLFloat()
+ {
+ LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987);
+ LSL_Types.list testList = new LSL_Types.list(testValue);
+
+ Assert.AreEqual(testValue, (LSL_Types.LSLFloat)testList.Data[0]);
+ }
+
+ ///
+ /// Tests casting LSLString item to LSLString.
+ ///
+ [Test]
+ public void TestCastLSLStringItemToLSLString()
+ {
+ LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there");
+ LSL_Types.list testList = new LSL_Types.list(testValue);
+
+ Assert.AreEqual(testValue, (LSL_Types.LSLString)testList.Data[0]);
+ }
+
+ ///
+ /// Tests casting Vector3 item to Vector3.
+ ///
+ [Test]
+ public void TestCastVector3ItemToVector3()
+ {
+ LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987);
+ LSL_Types.list testList = new LSL_Types.list(testValue);
+
+ Assert.AreEqual(testValue, (LSL_Types.Vector3)testList.Data[0]);
+ }
+ ///
+ /// Tests casting Quaternion item to Quaternion.
+ ///
+ [Test]
+ public void TestCastQuaternionItemToQuaternion()
+ {
+ LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987);
+ LSL_Types.list testList = new LSL_Types.list(testValue);
+
+ Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]);
+ }
+
+
}
}
--
cgit v1.1