clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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; |
||
29 | using System.Collections.Generic; |
||
30 | using NUnit.Framework; |
||
31 | using OpenSim.Framework; |
||
32 | using OpenSim.Tests.Common; |
||
33 | using OpenSim.Region.ScriptEngine.Shared; |
||
34 | using OpenSim.Region.Framework.Scenes; |
||
35 | using Nini.Config; |
||
36 | using OpenSim.Region.ScriptEngine.Shared.Api; |
||
37 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
||
38 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
||
39 | using OpenMetaverse; |
||
40 | using OpenSim.Tests.Common.Mock; |
||
41 | |||
42 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
||
43 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
||
44 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; |
||
45 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
||
48 | { |
||
49 | [TestFixture] |
||
50 | public class LSL_ApiListTests : OpenSimTestCase |
||
51 | { |
||
52 | private LSL_Api m_lslApi; |
||
53 | |||
54 | [SetUp] |
||
55 | public override void SetUp() |
||
56 | { |
||
57 | base.SetUp(); |
||
58 | |||
59 | IConfigSource initConfigSource = new IniConfigSource(); |
||
60 | IConfig config = initConfigSource.AddConfig("XEngine"); |
||
61 | config.Set("Enabled", "true"); |
||
62 | |||
63 | Scene scene = new SceneHelpers().SetupScene(); |
||
64 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; |
||
65 | |||
66 | XEngine.XEngine engine = new XEngine.XEngine(); |
||
67 | engine.Initialise(initConfigSource); |
||
68 | engine.AddRegion(scene); |
||
69 | |||
70 | m_lslApi = new LSL_Api(); |
||
71 | m_lslApi.Initialize(engine, part, null, null); |
||
72 | } |
||
73 | |||
74 | [Test] |
||
75 | public void TestllListFindList() |
||
76 | { |
||
77 | TestHelpers.InMethod(); |
||
78 | |||
79 | LSL_List src = new LSL_List(new LSL_Integer(1), new LSL_Integer(2), new LSL_Integer(3)); |
||
80 | |||
81 | { |
||
82 | // Test for a single item that should be found |
||
83 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); |
||
84 | Assert.That(result, Is.EqualTo(-1)); |
||
85 | } |
||
86 | |||
87 | { |
||
88 | // Test for a single item that should be found |
||
89 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2))); |
||
90 | Assert.That(result, Is.EqualTo(1)); |
||
91 | } |
||
92 | |||
93 | { |
||
94 | // Test for a constant that should be found |
||
95 | int result = m_lslApi.llListFindList(src, new LSL_List(ScriptBaseClass.AGENT)); |
||
96 | Assert.That(result, Is.EqualTo(0)); |
||
97 | } |
||
98 | |||
99 | { |
||
100 | // Test for a list that should be found |
||
101 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3))); |
||
102 | Assert.That(result, Is.EqualTo(1)); |
||
103 | } |
||
104 | |||
105 | { |
||
106 | // Test for a single item not in the list |
||
107 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); |
||
108 | Assert.That(result, Is.EqualTo(-1)); |
||
109 | } |
||
110 | |||
111 | { |
||
112 | // Test for something that should not be cast |
||
113 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_String("4"))); |
||
114 | Assert.That(result, Is.EqualTo(-1)); |
||
115 | } |
||
116 | |||
117 | { |
||
118 | // Test for a list not in the list |
||
119 | int result |
||
120 | = m_lslApi.llListFindList( |
||
121 | src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3), new LSL_Integer(4))); |
||
122 | Assert.That(result, Is.EqualTo(-1)); |
||
123 | } |
||
124 | |||
125 | { |
||
126 | LSL_List srcWithConstants |
||
127 | = new LSL_List(new LSL_Integer(3), ScriptBaseClass.AGENT, ScriptBaseClass.OS_NPC_LAND_AT_TARGET); |
||
128 | |||
129 | // Test for constants that appears in the source list that should be found |
||
130 | int result |
||
131 | = m_lslApi.llListFindList(srcWithConstants, new LSL_List(new LSL_Integer(1), new LSL_Integer(2))); |
||
132 | |||
133 | Assert.That(result, Is.EqualTo(1)); |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | } |