aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-03 18:57:06 +0000
committerMelanie Thielker2008-09-03 18:57:06 +0000
commitef27c8817fb2899b02116296001770005622f375 (patch)
tree2a75a9cabf187e670b848ccdb88eb43c7e76f8d0 /OpenSim/Tests
parentadd standard copyright headers for the project (diff)
downloadopensim-SC-ef27c8817fb2899b02116296001770005622f375.zip
opensim-SC-ef27c8817fb2899b02116296001770005622f375.tar.gz
opensim-SC-ef27c8817fb2899b02116296001770005622f375.tar.bz2
opensim-SC-ef27c8817fb2899b02116296001770005622f375.tar.xz
Mantis #2112
Thannk you, ralphos, for a patch to clean up list item type handling and add a missing explicit cast in Shared/
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLFloat.cs20
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestList.cs79
2 files changed, 90 insertions, 9 deletions
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
396 } 396 }
397 397
398 /// <summary> 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>
399 /// Tests the equality (==) operator. 419 /// Tests the equality (==) operator.
400 /// </summary> 420 /// </summary>
401 [Test] 421 [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
84 [Test] 84 [Test]
85 public void TestConcatenateDouble() 85 public void TestConcatenateDouble()
86 { 86 {
87 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test"); 87 LSL_Types.list testList = new LSL_Types.list(1, 'a', "test");
88 testList += 2.0; 88 testList += 2.0;
89 89
90 Assert.AreEqual(4, testList.Length); 90 Assert.AreEqual(4, testList.Length);
91 Assert.AreEqual(2.0, testList.Data[3]); 91 Assert.AreEqual(2.0, testList.Data[3]);
92 Assert.AreEqual(typeof(double), testList.Data[3].GetType()); 92 Assert.AreEqual(typeof(double), testList.Data[3].GetType());
93 93
94 LSL_Types.list secondTestList = testList + 0.04; 94 LSL_Types.list secondTestList = testList + 0.04;
95 95
96 Assert.AreEqual(5, secondTestList.Length); 96 Assert.AreEqual(5, secondTestList.Length);
97 Assert.AreEqual(0.04, secondTestList.Data[4]); 97 Assert.AreEqual(0.04, secondTestList.Data[4]);
98 Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType()); 98 Assert.AreEqual(typeof(double), 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]);
99 } 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
100 } 161 }
101} 162}