opensim-development – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 eva 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 {
35 /// <summary>
36 /// Tests the LSL_Types.list class.
37 /// </summary>
38 [TestFixture]
39 public class LSL_TypesTestList : OpenSimTestCase
40 {
41 /// <summary>
42 /// Tests concatenating a string to a list.
43 /// </summary>
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  
63 /// <summary>
64 /// Tests concatenating an integer to a list.
65 /// </summary>
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  
85 /// <summary>
86 /// Tests concatenating a float to a list.
87 /// </summary>
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  
107 /// <summary>
108 /// Tests casting LSLInteger item to LSLInteger.
109 /// </summary>
110 [Test]
111 public void TestCastLSLIntegerItemToLSLInteger()
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  
121 /// <summary>
122 /// Tests casting LSLFloat item to LSLFloat.
123 /// </summary>
124 [Test]
125 public void TestCastLSLFloatItemToLSLFloat()
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  
135 /// <summary>
136 /// Tests casting LSLString item to LSLString.
137 /// </summary>
138 [Test]
139 public void TestCastLSLStringItemToLSLString()
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  
149 /// <summary>
150 /// Tests casting Vector3 item to Vector3.
151 /// </summary>
152 [Test]
153 public void TestCastVector3ItemToVector3()
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 }
162 /// <summary>
163 /// Tests casting Quaternion item to Quaternion.
164 /// </summary>
165 [Test]
166 public void TestCastQuaternionItemToQuaternion()
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  
178 /// <summary>
179 /// Tests GetLSLIntegerItem for LSLInteger item.
180 /// </summary>
181 [Test]
182 public void TestGetLSLIntegerItemForLSLIntegerItem()
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  
192 /// <summary>
193 /// Tests GetLSLFloatItem for LSLFloat item.
194 /// </summary>
195 [Test]
196 public void TestGetLSLFloatItemForLSLFloatItem()
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  
206 /// <summary>
207 /// Tests GetLSLFloatItem for LSLInteger item.
208 /// </summary>
209 [Test]
210 public void TestGetLSLFloatItemForLSLIntegerItem()
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  
221 /// <summary>
222 /// Tests GetLSLStringItem for LSLString item.
223 /// </summary>
224 [Test]
225 public void TestGetLSLStringItemForLSLStringItem()
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  
235 /// <summary>
236 /// Tests GetLSLStringItem for key item.
237 /// </summary>
238 [Test]
239 public void TestGetLSLStringItemForKeyItem()
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  
251 /// <summary>
252 /// Tests GetVector3Item for Vector3 item.
253 /// </summary>
254 [Test]
255 public void TestGetVector3ItemForVector3Item()
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 }
264 /// <summary>
265 /// Tests GetQuaternionItem for Quaternion item.
266 /// </summary>
267 [Test]
268 public void TestGetQuaternionItemForQuaternionItem()
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  
278 /// <summary>
279 /// Tests GetKeyItem for key item.
280 /// </summary>
281 [Test]
282 public void TestGetKeyItemForKeyItem()
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 }