OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
LSL_TypesTestList.cs
Go to the documentation of this file.
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 OpenSimulator 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 
28 using System.Collections.Generic;
29 using NUnit.Framework;
30 using OpenSim.Tests.Common;
31 using OpenSim.Region.ScriptEngine.Shared;
32 
33 namespace OpenSim.Region.ScriptEngine.Shared.Tests
34 {
38  [TestFixture]
40  {
44  [Test]
45  public void TestConcatenateString()
46  {
47  TestHelpers.InMethod();
48 
49  LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
50  testList += new LSL_Types.LSLString("addition");
51 
52  Assert.AreEqual(4, testList.Length);
53  Assert.AreEqual(new LSL_Types.LSLString("addition"), testList.Data[3]);
54  Assert.AreEqual(typeof(LSL_Types.LSLString), testList.Data[3].GetType());
55 
56  LSL_Types.list secondTestList = testList + new LSL_Types.LSLString("more");
57 
58  Assert.AreEqual(5, secondTestList.Length);
59  Assert.AreEqual(new LSL_Types.LSLString("more"), secondTestList.Data[4]);
60  Assert.AreEqual(typeof(LSL_Types.LSLString), secondTestList.Data[4].GetType());
61  }
62 
66  [Test]
67  public void TestConcatenateInteger()
68  {
69  TestHelpers.InMethod();
70 
71  LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
72  testList += new LSL_Types.LSLInteger(20);
73 
74  Assert.AreEqual(4, testList.Length);
75  Assert.AreEqual(new LSL_Types.LSLInteger(20), testList.Data[3]);
76  Assert.AreEqual(typeof(LSL_Types.LSLInteger), testList.Data[3].GetType());
77 
78  LSL_Types.list secondTestList = testList + new LSL_Types.LSLInteger(2);
79 
80  Assert.AreEqual(5, secondTestList.Length);
81  Assert.AreEqual(new LSL_Types.LSLInteger(2), secondTestList.Data[4]);
82  Assert.AreEqual(typeof(LSL_Types.LSLInteger), secondTestList.Data[4].GetType());
83  }
84 
88  [Test]
89  public void TestConcatenateDouble()
90  {
91  TestHelpers.InMethod();
92 
93  LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test"));
94  testList += new LSL_Types.LSLFloat(2.0f);
95 
96  Assert.AreEqual(4, testList.Length);
97  Assert.AreEqual(new LSL_Types.LSLFloat(2.0f), testList.Data[3]);
98  Assert.AreEqual(typeof(LSL_Types.LSLFloat), testList.Data[3].GetType());
99 
100  LSL_Types.list secondTestList = testList + new LSL_Types.LSLFloat(0.04f);
101 
102  Assert.AreEqual(5, secondTestList.Length);
103  Assert.AreEqual(new LSL_Types.LSLFloat(0.04f), secondTestList.Data[4]);
104  Assert.AreEqual(typeof(LSL_Types.LSLFloat), secondTestList.Data[4].GetType());
105  }
106 
110  [Test]
112  {
113  TestHelpers.InMethod();
114 
115  LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123);
116  LSL_Types.list testList = new LSL_Types.list(testValue);
117 
118  Assert.AreEqual(testValue, (LSL_Types.LSLInteger)testList.Data[0]);
119  }
120 
124  [Test]
126  {
127  TestHelpers.InMethod();
128 
129  LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987);
130  LSL_Types.list testList = new LSL_Types.list(testValue);
131 
132  Assert.AreEqual(testValue, (LSL_Types.LSLFloat)testList.Data[0]);
133  }
134 
138  [Test]
140  {
141  TestHelpers.InMethod();
142 
143  LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there");
144  LSL_Types.list testList = new LSL_Types.list(testValue);
145 
146  Assert.AreEqual(testValue, (LSL_Types.LSLString)testList.Data[0]);
147  }
148 
152  [Test]
154  {
155  TestHelpers.InMethod();
156 
157  LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987);
158  LSL_Types.list testList = new LSL_Types.list(testValue);
159 
160  Assert.AreEqual(testValue, (LSL_Types.Vector3)testList.Data[0]);
161  }
165  [Test]
167  {
168  TestHelpers.InMethod();
169 
170  LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987);
171  LSL_Types.list testList = new LSL_Types.list(testValue);
172 
173  Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]);
174  }
175 
176 //====================================================================================
177 
181  [Test]
183  {
184  TestHelpers.InMethod();
185 
186  LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911);
187  LSL_Types.list testList = new LSL_Types.list(testValue);
188 
189  Assert.AreEqual(testValue, testList.GetLSLIntegerItem(0));
190  }
191 
195  [Test]
197  {
198  TestHelpers.InMethod();
199 
200  LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876);
201  LSL_Types.list testList = new LSL_Types.list(testValue);
202 
203  Assert.AreEqual(testValue, testList.GetLSLFloatItem(0));
204  }
205 
209  [Test]
211  {
212  TestHelpers.InMethod();
213 
214  LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987);
215  LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue);
216  LSL_Types.list testList = new LSL_Types.list(testValue);
217 
218  Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0));
219  }
220 
224  [Test]
226  {
227  TestHelpers.InMethod();
228 
229  LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all");
230  LSL_Types.list testList = new LSL_Types.list(testValue);
231 
232  Assert.AreEqual(testValue, testList.GetLSLStringItem(0));
233  }
234 
238  [Test]
240  {
241  TestHelpers.InMethod();
242 
243  LSL_Types.key testValue
244  = new LSL_Types.key("98000000-0000-2222-3333-100000001000");
245  LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue);
246  LSL_Types.list testList = new LSL_Types.list(testValue);
247 
248  Assert.AreEqual(testStringValue, testList.GetLSLStringItem(0));
249  }
250 
254  [Test]
256  {
257  TestHelpers.InMethod();
258 
259  LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987);
260  LSL_Types.list testList = new LSL_Types.list(testValue);
261 
262  Assert.AreEqual(testValue, testList.GetVector3Item(0));
263  }
267  [Test]
269  {
270  TestHelpers.InMethod();
271 
272  LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987);
273  LSL_Types.list testList = new LSL_Types.list(testValue);
274 
275  Assert.AreEqual(testValue, testList.GetQuaternionItem(0));
276  }
277 
281  [Test]
283  {
284  TestHelpers.InMethod();
285 
286  LSL_Types.key testValue
287  = new LSL_Types.key("00000000-0000-2222-3333-100000001012");
288  LSL_Types.list testList = new LSL_Types.list(testValue);
289 
290  Assert.AreEqual(testValue, testList.GetKeyItem(0));
291  }
292  }
293 }
void TestCastLSLIntegerItemToLSLInteger()
Tests casting LSLInteger item to LSLInteger.
void TestCastQuaternionItemToQuaternion()
Tests casting Quaternion item to Quaternion.
void TestGetLSLFloatItemForLSLFloatItem()
Tests GetLSLFloatItem for LSLFloat item.
void TestGetKeyItemForKeyItem()
Tests GetKeyItem for key item.
void TestConcatenateInteger()
Tests concatenating an integer to a list.
void TestCastVector3ItemToVector3()
Tests casting Vector3 item to Vector3.
void TestGetLSLStringItemForKeyItem()
Tests GetLSLStringItem for key item.
void TestGetLSLIntegerItemForLSLIntegerItem()
Tests GetLSLIntegerItem for LSLInteger item.
void TestCastLSLStringItemToLSLString()
Tests casting LSLString item to LSLString.
void TestConcatenateDouble()
Tests concatenating a float to a list.
void TestGetVector3ItemForVector3Item()
Tests GetVector3Item for Vector3 item.
void TestGetLSLFloatItemForLSLIntegerItem()
Tests GetLSLFloatItem for LSLInteger item.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSLInteger
Definition: CM_Constants.cs:31
void TestGetLSLStringItemForLSLStringItem()
Tests GetLSLStringItem for LSLString item.
void TestCastLSLFloatItemToLSLFloat()
Tests casting LSLFloat item to LSLFloat.
void TestConcatenateString()
Tests concatenating a string to a list.
void TestGetQuaternionItemForQuaternionItem()
Tests GetQuaternionItem for Quaternion item.