diff options
Diffstat (limited to 'OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLString.cs')
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLString.cs | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLString.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLString.cs new file mode 100644 index 0000000..0bba14c --- /dev/null +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLString.cs | |||
@@ -0,0 +1,112 @@ | |||
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 | |||
28 | using System.Collections.Generic; | ||
29 | using NUnit.Framework; | ||
30 | using OpenSim.Tests.Common; | ||
31 | using OpenSim.Region.ScriptEngine.Common; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Common.Tests | ||
34 | { | ||
35 | [TestFixture] | ||
36 | public class LSL_TypesTestLSLString | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Tests constructing a LSLString from an LSLFloat. | ||
40 | /// </summary> | ||
41 | [Test] | ||
42 | public void TestConstructFromLSLFloat() | ||
43 | { | ||
44 | // The numbers we test for. | ||
45 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); | ||
46 | numberSet.Add(2, "2.000000"); | ||
47 | numberSet.Add(-2, "-2.000000"); | ||
48 | numberSet.Add(0, "0.000000"); | ||
49 | numberSet.Add(1, "1.000000"); | ||
50 | numberSet.Add(-1, "-1.000000"); | ||
51 | numberSet.Add(999999999, "999999999.000000"); | ||
52 | numberSet.Add(-99999999, "-99999999.000000"); | ||
53 | numberSet.Add(0.5, "0.500000"); | ||
54 | numberSet.Add(0.0005, "0.000500"); | ||
55 | numberSet.Add(0.6805, "0.680500"); | ||
56 | numberSet.Add(-0.5, "-0.500000"); | ||
57 | numberSet.Add(-0.0005, "-0.000500"); | ||
58 | numberSet.Add(-0.6805, "-0.680500"); | ||
59 | numberSet.Add(548.5, "548.500000"); | ||
60 | numberSet.Add(2.0005, "2.000500"); | ||
61 | numberSet.Add(349485435.6805, "349485435.680500"); | ||
62 | numberSet.Add(-548.5, "-548.500000"); | ||
63 | numberSet.Add(-2.0005, "-2.000500"); | ||
64 | numberSet.Add(-349485435.6805, "-349485435.680500"); | ||
65 | |||
66 | LSL_Types.LSLString testString; | ||
67 | |||
68 | foreach (KeyValuePair<double, string> number in numberSet) | ||
69 | { | ||
70 | testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key)); | ||
71 | Assert.AreEqual(number.Value, testString.m_string); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Tests constructing a LSLString from an LSLFloat. | ||
77 | /// </summary> | ||
78 | [Test] | ||
79 | public void TestExplicitCastLSLFloatToLSLString() | ||
80 | { | ||
81 | // The numbers we test for. | ||
82 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); | ||
83 | numberSet.Add(2, "2.000000"); | ||
84 | numberSet.Add(-2, "-2.000000"); | ||
85 | numberSet.Add(0, "0.000000"); | ||
86 | numberSet.Add(1, "1.000000"); | ||
87 | numberSet.Add(-1, "-1.000000"); | ||
88 | numberSet.Add(999999999, "999999999.000000"); | ||
89 | numberSet.Add(-99999999, "-99999999.000000"); | ||
90 | numberSet.Add(0.5, "0.500000"); | ||
91 | numberSet.Add(0.0005, "0.000500"); | ||
92 | numberSet.Add(0.6805, "0.680500"); | ||
93 | numberSet.Add(-0.5, "-0.500000"); | ||
94 | numberSet.Add(-0.0005, "-0.000500"); | ||
95 | numberSet.Add(-0.6805, "-0.680500"); | ||
96 | numberSet.Add(548.5, "548.500000"); | ||
97 | numberSet.Add(2.0005, "2.000500"); | ||
98 | numberSet.Add(349485435.6805, "349485435.680500"); | ||
99 | numberSet.Add(-548.5, "-548.500000"); | ||
100 | numberSet.Add(-2.0005, "-2.000500"); | ||
101 | numberSet.Add(-349485435.6805, "-349485435.680500"); | ||
102 | |||
103 | LSL_Types.LSLString testString; | ||
104 | |||
105 | foreach (KeyValuePair<double, string> number in numberSet) | ||
106 | { | ||
107 | testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key); | ||
108 | Assert.AreEqual(number.Value, testString.m_string); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | } | ||