aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
diff options
context:
space:
mode:
authorSean Dague2008-09-08 20:34:45 +0000
committerSean Dague2008-09-08 20:34:45 +0000
commitce0a8d7beffccbaeb6b603a96b7729278c4c9e75 (patch)
treefaccd65637c0dab11b2dd787c8985cd7f2c9452b /OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
parentFix component order on a quaternion for the sit target. This caused (diff)
downloadopensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.zip
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.gz
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.bz2
opensim-SC_OLD-ce0a8d7beffccbaeb6b603a96b7729278c4c9e75.tar.xz
changes to Test directory structure per opensim-dev conversation
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
new file mode 100644
index 0000000..49e5023
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
@@ -0,0 +1,136 @@
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 OpenSim 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
28using System.Collections.Generic;
29using NUnit.Framework;
30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared;
32
33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{
35 [TestFixture]
36 public class LSL_TypesTestLSLString
37 {
38 private Dictionary<double, string> m_doubleStringSet;
39
40 /// <summary>
41 /// Sets up dictionaries and arrays used in the tests.
42 /// </summary>
43 [TestFixtureSetUp]
44 public void SetUpDataSets()
45 {
46 m_doubleStringSet = new Dictionary<double, string>();
47 m_doubleStringSet.Add(2, "2.000000");
48 m_doubleStringSet.Add(-2, "-2.000000");
49 m_doubleStringSet.Add(0, "0.000000");
50 m_doubleStringSet.Add(1, "1.000000");
51 m_doubleStringSet.Add(-1, "-1.000000");
52 m_doubleStringSet.Add(999999999, "999999999.000000");
53 m_doubleStringSet.Add(-99999999, "-99999999.000000");
54 m_doubleStringSet.Add(0.5, "0.500000");
55 m_doubleStringSet.Add(0.0005, "0.000500");
56 m_doubleStringSet.Add(0.6805, "0.680500");
57 m_doubleStringSet.Add(-0.5, "-0.500000");
58 m_doubleStringSet.Add(-0.0005, "-0.000500");
59 m_doubleStringSet.Add(-0.6805, "-0.680500");
60 m_doubleStringSet.Add(548.5, "548.500000");
61 m_doubleStringSet.Add(2.0005, "2.000500");
62 m_doubleStringSet.Add(349485435.6805, "349485435.680500");
63 m_doubleStringSet.Add(-548.5, "-548.500000");
64 m_doubleStringSet.Add(-2.0005, "-2.000500");
65 m_doubleStringSet.Add(-349485435.6805, "-349485435.680500");
66 }
67
68 /// <summary>
69 /// Tests constructing a LSLString from an LSLFloat.
70 /// </summary>
71 [Test]
72 public void TestConstructFromLSLFloat()
73 {
74 LSL_Types.LSLString testString;
75
76 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
77 {
78 testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key));
79 Assert.AreEqual(number.Value, testString.m_string);
80 }
81 }
82
83 /// <summary>
84 /// Tests constructing a LSLString from an LSLFloat.
85 /// </summary>
86 [Test]
87 public void TestExplicitCastLSLFloatToLSLString()
88 {
89 LSL_Types.LSLString testString;
90
91 foreach (KeyValuePair<double, string> number in m_doubleStringSet)
92 {
93 testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key);
94 Assert.AreEqual(number.Value, testString.m_string);
95 }
96 }
97
98 /// <summary>
99 /// Test constructing a Quaternion from a string.
100 /// </summary>
101 [Test]
102 public void TestExplicitCastLSLStringToQuaternion()
103 {
104 string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>";
105 LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString);
106
107 LSL_Types.Quaternion expectedQuaternion = new LSL_Types.Quaternion(0.0, 0.70711, 0.0, 0.70711);
108 LSL_Types.Quaternion stringQuaternion = (LSL_Types.Quaternion) quaternionString;
109 LSL_Types.Quaternion LSLStringQuaternion = (LSL_Types.Quaternion) quaternionLSLString;
110
111 Assert.AreEqual(expectedQuaternion, stringQuaternion);
112 Assert.AreEqual(expectedQuaternion, LSLStringQuaternion);
113 }
114
115 /// <summary>
116 /// Tests boolean correctly cast explicitly to LSLString.
117 /// </summary>
118 [Test]
119 public void TestImplicitCastBooleanToLSLFloat()
120 {
121 LSL_Types.LSLString testString;
122
123 testString = (LSL_Types.LSLString) (1 == 0);
124 Assert.AreEqual("0", testString.m_string);
125
126 testString = (LSL_Types.LSLString) (1 == 1);
127 Assert.AreEqual("1", testString.m_string);
128
129 testString = (LSL_Types.LSLString) false;
130 Assert.AreEqual("0", testString.m_string);
131
132 testString = (LSL_Types.LSLString) true;
133 Assert.AreEqual("1", testString.m_string);
134 }
135 }
136}