diff options
author | Jeff Ames | 2008-06-06 00:25:43 +0000 |
---|---|---|
committer | Jeff Ames | 2008-06-06 00:25:43 +0000 |
commit | 2818dd800e2e41665b4d7fcc0f1ada6532893d76 (patch) | |
tree | 013454aec10efb2298d679b45979cc41d65d0f01 | |
parent | Mantis#1451. Thank you kindly, mikem for additional (diff) | |
download | opensim-SC-2818dd800e2e41665b4d7fcc0f1ada6532893d76.zip opensim-SC-2818dd800e2e41665b4d7fcc0f1ada6532893d76.tar.gz opensim-SC-2818dd800e2e41665b4d7fcc0f1ada6532893d76.tar.bz2 opensim-SC-2818dd800e2e41665b4d7fcc0f1ada6532893d76.tar.xz |
Update svn properties.
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs | 1158 | ||||
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs | 224 |
2 files changed, 691 insertions, 691 deletions
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs index a94370e..4af9df7 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLFloat.cs | |||
@@ -1,579 +1,579 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenSim.Tests.Common; | 30 | using OpenSim.Tests.Common; |
31 | using OpenSim.Region.ScriptEngine.Common; | 31 | using OpenSim.Region.ScriptEngine.Common; |
32 | using System; | 32 | using System; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.Common.Tests | 34 | namespace OpenSim.Region.ScriptEngine.Common.Tests |
35 | { | 35 | { |
36 | [TestFixture] | 36 | [TestFixture] |
37 | public class LSL_TypesTestLSLFloat | 37 | public class LSL_TypesTestLSLFloat |
38 | { | 38 | { |
39 | // Used for testing equality of two floats. | 39 | // Used for testing equality of two floats. |
40 | private double _lowPrecisionTolerance = 0.000001; | 40 | private double _lowPrecisionTolerance = 0.000001; |
41 | 41 | ||
42 | /// <summary> | 42 | /// <summary> |
43 | /// Tests constructing a LSLFloat from an integer. | 43 | /// Tests constructing a LSLFloat from an integer. |
44 | /// </summary> | 44 | /// </summary> |
45 | [Test] | 45 | [Test] |
46 | public void TestConstructFromInt() | 46 | public void TestConstructFromInt() |
47 | { | 47 | { |
48 | // The numbers we test for. | 48 | // The numbers we test for. |
49 | Dictionary<int, double> numberSet = new Dictionary<int, double>(); | 49 | Dictionary<int, double> numberSet = new Dictionary<int, double>(); |
50 | numberSet.Add(2, 2.0); | 50 | numberSet.Add(2, 2.0); |
51 | numberSet.Add(-2, -2.0); | 51 | numberSet.Add(-2, -2.0); |
52 | numberSet.Add(0, 0.0); | 52 | numberSet.Add(0, 0.0); |
53 | numberSet.Add(1, 1.0); | 53 | numberSet.Add(1, 1.0); |
54 | numberSet.Add(-1, -1.0); | 54 | numberSet.Add(-1, -1.0); |
55 | numberSet.Add(999999999, 999999999.0); | 55 | numberSet.Add(999999999, 999999999.0); |
56 | numberSet.Add(-99999999, -99999999.0); | 56 | numberSet.Add(-99999999, -99999999.0); |
57 | 57 | ||
58 | LSL_Types.LSLFloat testFloat; | 58 | LSL_Types.LSLFloat testFloat; |
59 | 59 | ||
60 | foreach(KeyValuePair<int, double> number in numberSet) | 60 | foreach(KeyValuePair<int, double> number in numberSet) |
61 | { | 61 | { |
62 | testFloat = new LSL_Types.LSLFloat(number.Key); | 62 | testFloat = new LSL_Types.LSLFloat(number.Key); |
63 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); | 63 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | /// <summary> | 67 | /// <summary> |
68 | /// Tests constructing a LSLFloat from a double. | 68 | /// Tests constructing a LSLFloat from a double. |
69 | /// </summary> | 69 | /// </summary> |
70 | [Test] | 70 | [Test] |
71 | public void TestConstructFromDouble() | 71 | public void TestConstructFromDouble() |
72 | { | 72 | { |
73 | // The numbers we test for. | 73 | // The numbers we test for. |
74 | Dictionary<double, double> numberSet = new Dictionary<double, double>(); | 74 | Dictionary<double, double> numberSet = new Dictionary<double, double>(); |
75 | numberSet.Add(2.0, 2.0); | 75 | numberSet.Add(2.0, 2.0); |
76 | numberSet.Add(-2.0, -2.0); | 76 | numberSet.Add(-2.0, -2.0); |
77 | numberSet.Add(0.0, 0.0); | 77 | numberSet.Add(0.0, 0.0); |
78 | numberSet.Add(1.0, 1.0); | 78 | numberSet.Add(1.0, 1.0); |
79 | numberSet.Add(-1.0, -1.0); | 79 | numberSet.Add(-1.0, -1.0); |
80 | numberSet.Add(999999999.0, 999999999.0); | 80 | numberSet.Add(999999999.0, 999999999.0); |
81 | numberSet.Add(-99999999.0, -99999999.0); | 81 | numberSet.Add(-99999999.0, -99999999.0); |
82 | numberSet.Add(0.5, 0.5); | 82 | numberSet.Add(0.5, 0.5); |
83 | numberSet.Add(0.0005, 0.0005); | 83 | numberSet.Add(0.0005, 0.0005); |
84 | numberSet.Add(0.6805, 0.6805); | 84 | numberSet.Add(0.6805, 0.6805); |
85 | numberSet.Add(-0.5, -0.5); | 85 | numberSet.Add(-0.5, -0.5); |
86 | numberSet.Add(-0.0005, -0.0005); | 86 | numberSet.Add(-0.0005, -0.0005); |
87 | numberSet.Add(-0.6805, -0.6805); | 87 | numberSet.Add(-0.6805, -0.6805); |
88 | numberSet.Add(548.5, 548.5); | 88 | numberSet.Add(548.5, 548.5); |
89 | numberSet.Add(2.0005, 2.0005); | 89 | numberSet.Add(2.0005, 2.0005); |
90 | numberSet.Add(349485435.6805, 349485435.6805); | 90 | numberSet.Add(349485435.6805, 349485435.6805); |
91 | numberSet.Add(-548.5, -548.5); | 91 | numberSet.Add(-548.5, -548.5); |
92 | numberSet.Add(-2.0005, -2.0005); | 92 | numberSet.Add(-2.0005, -2.0005); |
93 | numberSet.Add(-349485435.6805, -349485435.6805); | 93 | numberSet.Add(-349485435.6805, -349485435.6805); |
94 | 94 | ||
95 | LSL_Types.LSLFloat testFloat; | 95 | LSL_Types.LSLFloat testFloat; |
96 | 96 | ||
97 | foreach(KeyValuePair<double, double> number in numberSet) | 97 | foreach(KeyValuePair<double, double> number in numberSet) |
98 | { | 98 | { |
99 | testFloat = new LSL_Types.LSLFloat(number.Key); | 99 | testFloat = new LSL_Types.LSLFloat(number.Key); |
100 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); | 100 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | /// <summary> | 104 | /// <summary> |
105 | /// Tests LSLFloat is correctly cast implicitly to integer. | 105 | /// Tests LSLFloat is correctly cast implicitly to integer. |
106 | /// </summary> | 106 | /// </summary> |
107 | [Test] | 107 | [Test] |
108 | public void TestImplicitCastLSLFloatToInt() | 108 | public void TestImplicitCastLSLFloatToInt() |
109 | { | 109 | { |
110 | // The numbers we test for. | 110 | // The numbers we test for. |
111 | Dictionary<double, int> numberSet = new Dictionary<double, int>(); | 111 | Dictionary<double, int> numberSet = new Dictionary<double, int>(); |
112 | numberSet.Add(2.0, 2); | 112 | numberSet.Add(2.0, 2); |
113 | numberSet.Add(-2.0, -2); | 113 | numberSet.Add(-2.0, -2); |
114 | numberSet.Add(0.0, 0); | 114 | numberSet.Add(0.0, 0); |
115 | numberSet.Add(1.0, 1); | 115 | numberSet.Add(1.0, 1); |
116 | numberSet.Add(-1.0, -1); | 116 | numberSet.Add(-1.0, -1); |
117 | numberSet.Add(999999999.0, 999999999); | 117 | numberSet.Add(999999999.0, 999999999); |
118 | numberSet.Add(-99999999.0, -99999999); | 118 | numberSet.Add(-99999999.0, -99999999); |
119 | numberSet.Add(0.5, 0); | 119 | numberSet.Add(0.5, 0); |
120 | numberSet.Add(0.0005, 0); | 120 | numberSet.Add(0.0005, 0); |
121 | numberSet.Add(0.6805, 0); | 121 | numberSet.Add(0.6805, 0); |
122 | numberSet.Add(-0.5, 0); | 122 | numberSet.Add(-0.5, 0); |
123 | numberSet.Add(-0.0005, 0); | 123 | numberSet.Add(-0.0005, 0); |
124 | numberSet.Add(-0.6805, 0); | 124 | numberSet.Add(-0.6805, 0); |
125 | numberSet.Add(548.5, 548); | 125 | numberSet.Add(548.5, 548); |
126 | numberSet.Add(2.0005, 2); | 126 | numberSet.Add(2.0005, 2); |
127 | numberSet.Add(349485435.6805, 349485435); | 127 | numberSet.Add(349485435.6805, 349485435); |
128 | numberSet.Add(-548.5, -548); | 128 | numberSet.Add(-548.5, -548); |
129 | numberSet.Add(-2.0005, -2); | 129 | numberSet.Add(-2.0005, -2); |
130 | numberSet.Add(-349485435.6805, -349485435); | 130 | numberSet.Add(-349485435.6805, -349485435); |
131 | 131 | ||
132 | int testNumber; | 132 | int testNumber; |
133 | 133 | ||
134 | foreach(KeyValuePair<double, int> number in numberSet) | 134 | foreach(KeyValuePair<double, int> number in numberSet) |
135 | { | 135 | { |
136 | testNumber = new LSL_Types.LSLFloat(number.Key); | 136 | testNumber = new LSL_Types.LSLFloat(number.Key); |
137 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); | 137 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting int " + number.Value); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | /// <summary> | 141 | /// <summary> |
142 | /// Tests LSLFloat is correctly cast implicitly to unsigned integer. | 142 | /// Tests LSLFloat is correctly cast implicitly to unsigned integer. |
143 | /// </summary> | 143 | /// </summary> |
144 | [Test] | 144 | [Test] |
145 | public void TestImplicitCastLSLFloatToUint() | 145 | public void TestImplicitCastLSLFloatToUint() |
146 | { | 146 | { |
147 | // The numbers we test for. | 147 | // The numbers we test for. |
148 | Dictionary<double, int> numberSet = new Dictionary<double, int>(); | 148 | Dictionary<double, int> numberSet = new Dictionary<double, int>(); |
149 | numberSet.Add(2.0, 2); | 149 | numberSet.Add(2.0, 2); |
150 | numberSet.Add(-2.0, 2); | 150 | numberSet.Add(-2.0, 2); |
151 | numberSet.Add(0.0, 0); | 151 | numberSet.Add(0.0, 0); |
152 | numberSet.Add(1.0, 1); | 152 | numberSet.Add(1.0, 1); |
153 | numberSet.Add(-1.0, 1); | 153 | numberSet.Add(-1.0, 1); |
154 | numberSet.Add(999999999.0, 999999999); | 154 | numberSet.Add(999999999.0, 999999999); |
155 | numberSet.Add(-99999999.0, 99999999); | 155 | numberSet.Add(-99999999.0, 99999999); |
156 | numberSet.Add(0.5, 0); | 156 | numberSet.Add(0.5, 0); |
157 | numberSet.Add(0.0005, 0); | 157 | numberSet.Add(0.0005, 0); |
158 | numberSet.Add(0.6805, 0); | 158 | numberSet.Add(0.6805, 0); |
159 | numberSet.Add(-0.5, 0); | 159 | numberSet.Add(-0.5, 0); |
160 | numberSet.Add(-0.0005, 0); | 160 | numberSet.Add(-0.0005, 0); |
161 | numberSet.Add(-0.6805, 0); | 161 | numberSet.Add(-0.6805, 0); |
162 | numberSet.Add(548.5, 548); | 162 | numberSet.Add(548.5, 548); |
163 | numberSet.Add(2.0005, 2); | 163 | numberSet.Add(2.0005, 2); |
164 | numberSet.Add(349485435.6805, 349485435); | 164 | numberSet.Add(349485435.6805, 349485435); |
165 | numberSet.Add(-548.5, 548); | 165 | numberSet.Add(-548.5, 548); |
166 | numberSet.Add(-2.0005, 2); | 166 | numberSet.Add(-2.0005, 2); |
167 | numberSet.Add(-349485435.6805, 349485435); | 167 | numberSet.Add(-349485435.6805, 349485435); |
168 | 168 | ||
169 | uint testNumber; | 169 | uint testNumber; |
170 | 170 | ||
171 | foreach(KeyValuePair<double, int> number in numberSet) | 171 | foreach(KeyValuePair<double, int> number in numberSet) |
172 | { | 172 | { |
173 | testNumber = new LSL_Types.LSLFloat(number.Key); | 173 | testNumber = new LSL_Types.LSLFloat(number.Key); |
174 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); | 174 | Assert.AreEqual(number.Value, testNumber, "Converting double " + number.Key + ", expecting uint " + number.Value); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | /// <summary> | 178 | /// <summary> |
179 | /// Tests LSLFloat is correctly cast implicitly to Boolean if non-zero. | 179 | /// Tests LSLFloat is correctly cast implicitly to Boolean if non-zero. |
180 | /// </summary> | 180 | /// </summary> |
181 | [Test] | 181 | [Test] |
182 | public void TestImplicitCastLSLFloatToBooleanTrue() | 182 | public void TestImplicitCastLSLFloatToBooleanTrue() |
183 | { | 183 | { |
184 | // A bunch of numbers to test with. | 184 | // A bunch of numbers to test with. |
185 | List<double> numberList = new List<double>(); | 185 | List<double> numberList = new List<double>(); |
186 | numberList.Add(2.0); | 186 | numberList.Add(2.0); |
187 | numberList.Add(-2.0); | 187 | numberList.Add(-2.0); |
188 | numberList.Add(1.0); | 188 | numberList.Add(1.0); |
189 | numberList.Add(-1.0); | 189 | numberList.Add(-1.0); |
190 | numberList.Add(999999999.0); | 190 | numberList.Add(999999999.0); |
191 | numberList.Add(-99999999.0); | 191 | numberList.Add(-99999999.0); |
192 | numberList.Add(0.5); | 192 | numberList.Add(0.5); |
193 | numberList.Add(0.0005); | 193 | numberList.Add(0.0005); |
194 | numberList.Add(0.6805); | 194 | numberList.Add(0.6805); |
195 | numberList.Add(-0.5); | 195 | numberList.Add(-0.5); |
196 | numberList.Add(-0.0005); | 196 | numberList.Add(-0.0005); |
197 | numberList.Add(-0.6805); | 197 | numberList.Add(-0.6805); |
198 | numberList.Add(548.5); | 198 | numberList.Add(548.5); |
199 | numberList.Add(2.0005); | 199 | numberList.Add(2.0005); |
200 | numberList.Add(349485435.6805); | 200 | numberList.Add(349485435.6805); |
201 | numberList.Add(-548.5); | 201 | numberList.Add(-548.5); |
202 | numberList.Add(-2.0005); | 202 | numberList.Add(-2.0005); |
203 | numberList.Add(-349485435.6805); | 203 | numberList.Add(-349485435.6805); |
204 | 204 | ||
205 | LSL_Types.LSLFloat testFloat; | 205 | LSL_Types.LSLFloat testFloat; |
206 | bool testBool; | 206 | bool testBool; |
207 | 207 | ||
208 | foreach(double number in numberList) | 208 | foreach(double number in numberList) |
209 | { | 209 | { |
210 | testFloat = new LSL_Types.LSLFloat(number); | 210 | testFloat = new LSL_Types.LSLFloat(number); |
211 | testBool = testFloat; | 211 | testBool = testFloat; |
212 | 212 | ||
213 | Assert.IsTrue(testBool); | 213 | Assert.IsTrue(testBool); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | /// <summary> | 217 | /// <summary> |
218 | /// Tests LSLFloat is correctly cast implicitly to Boolean if zero. | 218 | /// Tests LSLFloat is correctly cast implicitly to Boolean if zero. |
219 | /// </summary> | 219 | /// </summary> |
220 | [Test] | 220 | [Test] |
221 | public void TestImplicitCastLSLFloatToBooleanFalse() | 221 | public void TestImplicitCastLSLFloatToBooleanFalse() |
222 | { | 222 | { |
223 | LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); | 223 | LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); |
224 | bool testBool = testFloat; | 224 | bool testBool = testFloat; |
225 | 225 | ||
226 | Assert.IsFalse(testBool); | 226 | Assert.IsFalse(testBool); |
227 | } | 227 | } |
228 | 228 | ||
229 | /// <summary> | 229 | /// <summary> |
230 | /// Tests integer is correctly cast implicitly to LSLFloat. | 230 | /// Tests integer is correctly cast implicitly to LSLFloat. |
231 | /// </summary> | 231 | /// </summary> |
232 | [Test] | 232 | [Test] |
233 | public void TestImplicitCastIntToLSLFloat() | 233 | public void TestImplicitCastIntToLSLFloat() |
234 | { | 234 | { |
235 | // A bunch of numbers to test with. | 235 | // A bunch of numbers to test with. |
236 | List<int> numberList = new List<int>(); | 236 | List<int> numberList = new List<int>(); |
237 | numberList.Add(2); | 237 | numberList.Add(2); |
238 | numberList.Add(-2); | 238 | numberList.Add(-2); |
239 | numberList.Add(0); | 239 | numberList.Add(0); |
240 | numberList.Add(1); | 240 | numberList.Add(1); |
241 | numberList.Add(-1); | 241 | numberList.Add(-1); |
242 | numberList.Add(999999999); | 242 | numberList.Add(999999999); |
243 | numberList.Add(-99999999); | 243 | numberList.Add(-99999999); |
244 | 244 | ||
245 | LSL_Types.LSLFloat testFloat; | 245 | LSL_Types.LSLFloat testFloat; |
246 | 246 | ||
247 | foreach(int number in numberList) | 247 | foreach(int number in numberList) |
248 | { | 248 | { |
249 | testFloat = number; | 249 | testFloat = number; |
250 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | 250 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | /// <summary> | 254 | /// <summary> |
255 | /// Tests string is correctly cast implicitly to LSLFloat. | 255 | /// Tests string is correctly cast implicitly to LSLFloat. |
256 | /// </summary> | 256 | /// </summary> |
257 | [Test] | 257 | [Test] |
258 | public void TestImplicitCastStringToLSLFloat() | 258 | public void TestImplicitCastStringToLSLFloat() |
259 | { | 259 | { |
260 | // A bunch of numbers to test with. | 260 | // A bunch of numbers to test with. |
261 | Dictionary<string, double> numberSet = new Dictionary<string, double>(); | 261 | Dictionary<string, double> numberSet = new Dictionary<string, double>(); |
262 | numberSet.Add("2", 2.0); | 262 | numberSet.Add("2", 2.0); |
263 | numberSet.Add("-2", -2.0); | 263 | numberSet.Add("-2", -2.0); |
264 | numberSet.Add("1", 1.0); | 264 | numberSet.Add("1", 1.0); |
265 | numberSet.Add("-1", -1.0); | 265 | numberSet.Add("-1", -1.0); |
266 | numberSet.Add("0", 0.0); | 266 | numberSet.Add("0", 0.0); |
267 | numberSet.Add("999999999.0", 999999999.0); | 267 | numberSet.Add("999999999.0", 999999999.0); |
268 | numberSet.Add("-99999999.0", -99999999.0); | 268 | numberSet.Add("-99999999.0", -99999999.0); |
269 | numberSet.Add("0.5", 0.5); | 269 | numberSet.Add("0.5", 0.5); |
270 | numberSet.Add("0.0005", 0.0005); | 270 | numberSet.Add("0.0005", 0.0005); |
271 | numberSet.Add("0.6805", 0.6805); | 271 | numberSet.Add("0.6805", 0.6805); |
272 | numberSet.Add("-0.5", -0.5); | 272 | numberSet.Add("-0.5", -0.5); |
273 | numberSet.Add("-0.0005", -0.0005); | 273 | numberSet.Add("-0.0005", -0.0005); |
274 | numberSet.Add("-0.6805", -0.6805); | 274 | numberSet.Add("-0.6805", -0.6805); |
275 | numberSet.Add("548.5", 548.5); | 275 | numberSet.Add("548.5", 548.5); |
276 | numberSet.Add("2.0005", 2.0005); | 276 | numberSet.Add("2.0005", 2.0005); |
277 | numberSet.Add("349485435.6805", 349485435.6805); | 277 | numberSet.Add("349485435.6805", 349485435.6805); |
278 | numberSet.Add("-548.5", -548.5); | 278 | numberSet.Add("-548.5", -548.5); |
279 | numberSet.Add("-2.0005", -2.0005); | 279 | numberSet.Add("-2.0005", -2.0005); |
280 | numberSet.Add("-349485435.6805", -349485435.6805); | 280 | numberSet.Add("-349485435.6805", -349485435.6805); |
281 | 281 | ||
282 | LSL_Types.LSLFloat testFloat; | 282 | LSL_Types.LSLFloat testFloat; |
283 | 283 | ||
284 | foreach(KeyValuePair<string, double> number in numberSet) | 284 | foreach(KeyValuePair<string, double> number in numberSet) |
285 | { | 285 | { |
286 | testFloat = number.Key; | 286 | testFloat = number.Key; |
287 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); | 287 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number.Value, _lowPrecisionTolerance)); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | /// <summary> | 291 | /// <summary> |
292 | /// Tests double is correctly cast implicitly to LSLFloat. | 292 | /// Tests double is correctly cast implicitly to LSLFloat. |
293 | /// </summary> | 293 | /// </summary> |
294 | [Test] | 294 | [Test] |
295 | public void TestImplicitCastDoubleToLSLFloat() | 295 | public void TestImplicitCastDoubleToLSLFloat() |
296 | { | 296 | { |
297 | // A bunch of numbers to test with. | 297 | // A bunch of numbers to test with. |
298 | List<double> numberList = new List<double>(); | 298 | List<double> numberList = new List<double>(); |
299 | numberList.Add(2.0); | 299 | numberList.Add(2.0); |
300 | numberList.Add(-2.0); | 300 | numberList.Add(-2.0); |
301 | numberList.Add(1.0); | 301 | numberList.Add(1.0); |
302 | numberList.Add(-1.0); | 302 | numberList.Add(-1.0); |
303 | numberList.Add(0.0); | 303 | numberList.Add(0.0); |
304 | numberList.Add(999999999.0); | 304 | numberList.Add(999999999.0); |
305 | numberList.Add(-99999999.0); | 305 | numberList.Add(-99999999.0); |
306 | numberList.Add(0.5); | 306 | numberList.Add(0.5); |
307 | numberList.Add(0.0005); | 307 | numberList.Add(0.0005); |
308 | numberList.Add(0.6805); | 308 | numberList.Add(0.6805); |
309 | numberList.Add(-0.5); | 309 | numberList.Add(-0.5); |
310 | numberList.Add(-0.0005); | 310 | numberList.Add(-0.0005); |
311 | numberList.Add(-0.6805); | 311 | numberList.Add(-0.6805); |
312 | numberList.Add(548.5); | 312 | numberList.Add(548.5); |
313 | numberList.Add(2.0005); | 313 | numberList.Add(2.0005); |
314 | numberList.Add(349485435.6805); | 314 | numberList.Add(349485435.6805); |
315 | numberList.Add(-548.5); | 315 | numberList.Add(-548.5); |
316 | numberList.Add(-2.0005); | 316 | numberList.Add(-2.0005); |
317 | numberList.Add(-349485435.6805); | 317 | numberList.Add(-349485435.6805); |
318 | 318 | ||
319 | LSL_Types.LSLFloat testFloat; | 319 | LSL_Types.LSLFloat testFloat; |
320 | 320 | ||
321 | foreach(double number in numberList) | 321 | foreach(double number in numberList) |
322 | { | 322 | { |
323 | testFloat = number; | 323 | testFloat = number; |
324 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | 324 | Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | /// <summary> | 328 | /// <summary> |
329 | /// Tests the equality (==) operator. | 329 | /// Tests the equality (==) operator. |
330 | /// </summary> | 330 | /// </summary> |
331 | [Test] | 331 | [Test] |
332 | public void TestEqualsOperator() | 332 | public void TestEqualsOperator() |
333 | { | 333 | { |
334 | // A bunch of numbers to test with. | 334 | // A bunch of numbers to test with. |
335 | List<double> numberList = new List<double>(); | 335 | List<double> numberList = new List<double>(); |
336 | numberList.Add(2.0); | 336 | numberList.Add(2.0); |
337 | numberList.Add(-2.0); | 337 | numberList.Add(-2.0); |
338 | numberList.Add(1.0); | 338 | numberList.Add(1.0); |
339 | numberList.Add(-1.0); | 339 | numberList.Add(-1.0); |
340 | numberList.Add(0.0); | 340 | numberList.Add(0.0); |
341 | numberList.Add(999999999.0); | 341 | numberList.Add(999999999.0); |
342 | numberList.Add(-99999999.0); | 342 | numberList.Add(-99999999.0); |
343 | numberList.Add(0.5); | 343 | numberList.Add(0.5); |
344 | numberList.Add(0.0005); | 344 | numberList.Add(0.0005); |
345 | numberList.Add(0.6805); | 345 | numberList.Add(0.6805); |
346 | numberList.Add(-0.5); | 346 | numberList.Add(-0.5); |
347 | numberList.Add(-0.0005); | 347 | numberList.Add(-0.0005); |
348 | numberList.Add(-0.6805); | 348 | numberList.Add(-0.6805); |
349 | numberList.Add(548.5); | 349 | numberList.Add(548.5); |
350 | numberList.Add(2.0005); | 350 | numberList.Add(2.0005); |
351 | numberList.Add(349485435.6805); | 351 | numberList.Add(349485435.6805); |
352 | numberList.Add(-548.5); | 352 | numberList.Add(-548.5); |
353 | numberList.Add(-2.0005); | 353 | numberList.Add(-2.0005); |
354 | numberList.Add(-349485435.6805); | 354 | numberList.Add(-349485435.6805); |
355 | 355 | ||
356 | LSL_Types.LSLFloat testFloatA, testFloatB; | 356 | LSL_Types.LSLFloat testFloatA, testFloatB; |
357 | 357 | ||
358 | foreach(double number in numberList) | 358 | foreach(double number in numberList) |
359 | { | 359 | { |
360 | testFloatA = new LSL_Types.LSLFloat(number); | 360 | testFloatA = new LSL_Types.LSLFloat(number); |
361 | testFloatB = new LSL_Types.LSLFloat(number); | 361 | testFloatB = new LSL_Types.LSLFloat(number); |
362 | Assert.IsTrue(testFloatA == testFloatB); | 362 | Assert.IsTrue(testFloatA == testFloatB); |
363 | 363 | ||
364 | testFloatB = new LSL_Types.LSLFloat(number + 1.0); | 364 | testFloatB = new LSL_Types.LSLFloat(number + 1.0); |
365 | Assert.IsFalse(testFloatA == testFloatB); | 365 | Assert.IsFalse(testFloatA == testFloatB); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | /// <summary> | 369 | /// <summary> |
370 | /// Tests the inequality (!=) operator. | 370 | /// Tests the inequality (!=) operator. |
371 | /// </summary> | 371 | /// </summary> |
372 | [Test] | 372 | [Test] |
373 | public void TestNotEqualOperator() | 373 | public void TestNotEqualOperator() |
374 | { | 374 | { |
375 | // A bunch of numbers to test with. | 375 | // A bunch of numbers to test with. |
376 | List<double> numberList = new List<double>(); | 376 | List<double> numberList = new List<double>(); |
377 | numberList.Add(2.0); | 377 | numberList.Add(2.0); |
378 | numberList.Add(-2.0); | 378 | numberList.Add(-2.0); |
379 | numberList.Add(1.0); | 379 | numberList.Add(1.0); |
380 | numberList.Add(-1.0); | 380 | numberList.Add(-1.0); |
381 | numberList.Add(0.0); | 381 | numberList.Add(0.0); |
382 | numberList.Add(999999999.0); | 382 | numberList.Add(999999999.0); |
383 | numberList.Add(-99999999.0); | 383 | numberList.Add(-99999999.0); |
384 | numberList.Add(0.5); | 384 | numberList.Add(0.5); |
385 | numberList.Add(0.0005); | 385 | numberList.Add(0.0005); |
386 | numberList.Add(0.6805); | 386 | numberList.Add(0.6805); |
387 | numberList.Add(-0.5); | 387 | numberList.Add(-0.5); |
388 | numberList.Add(-0.0005); | 388 | numberList.Add(-0.0005); |
389 | numberList.Add(-0.6805); | 389 | numberList.Add(-0.6805); |
390 | numberList.Add(548.5); | 390 | numberList.Add(548.5); |
391 | numberList.Add(2.0005); | 391 | numberList.Add(2.0005); |
392 | numberList.Add(349485435.6805); | 392 | numberList.Add(349485435.6805); |
393 | numberList.Add(-548.5); | 393 | numberList.Add(-548.5); |
394 | numberList.Add(-2.0005); | 394 | numberList.Add(-2.0005); |
395 | numberList.Add(-349485435.6805); | 395 | numberList.Add(-349485435.6805); |
396 | 396 | ||
397 | LSL_Types.LSLFloat testFloatA, testFloatB; | 397 | LSL_Types.LSLFloat testFloatA, testFloatB; |
398 | 398 | ||
399 | foreach(double number in numberList) | 399 | foreach(double number in numberList) |
400 | { | 400 | { |
401 | testFloatA = new LSL_Types.LSLFloat(number); | 401 | testFloatA = new LSL_Types.LSLFloat(number); |
402 | testFloatB = new LSL_Types.LSLFloat(number + 1.0); | 402 | testFloatB = new LSL_Types.LSLFloat(number + 1.0); |
403 | Assert.IsTrue(testFloatA != testFloatB); | 403 | Assert.IsTrue(testFloatA != testFloatB); |
404 | 404 | ||
405 | testFloatB = new LSL_Types.LSLFloat(number); | 405 | testFloatB = new LSL_Types.LSLFloat(number); |
406 | Assert.IsFalse(testFloatA != testFloatB); | 406 | Assert.IsFalse(testFloatA != testFloatB); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | /// <summary> | 410 | /// <summary> |
411 | /// Tests the increment operator. | 411 | /// Tests the increment operator. |
412 | /// </summary> | 412 | /// </summary> |
413 | [Test] | 413 | [Test] |
414 | public void TestIncrementOperator() | 414 | public void TestIncrementOperator() |
415 | { | 415 | { |
416 | // A bunch of numbers to test with. | 416 | // A bunch of numbers to test with. |
417 | List<double> numberList = new List<double>(); | 417 | List<double> numberList = new List<double>(); |
418 | numberList.Add(2.0); | 418 | numberList.Add(2.0); |
419 | numberList.Add(-2.0); | 419 | numberList.Add(-2.0); |
420 | numberList.Add(1.0); | 420 | numberList.Add(1.0); |
421 | numberList.Add(-1.0); | 421 | numberList.Add(-1.0); |
422 | numberList.Add(0.0); | 422 | numberList.Add(0.0); |
423 | numberList.Add(999999999.0); | 423 | numberList.Add(999999999.0); |
424 | numberList.Add(-99999999.0); | 424 | numberList.Add(-99999999.0); |
425 | numberList.Add(0.5); | 425 | numberList.Add(0.5); |
426 | numberList.Add(0.0005); | 426 | numberList.Add(0.0005); |
427 | numberList.Add(0.6805); | 427 | numberList.Add(0.6805); |
428 | numberList.Add(-0.5); | 428 | numberList.Add(-0.5); |
429 | numberList.Add(-0.0005); | 429 | numberList.Add(-0.0005); |
430 | numberList.Add(-0.6805); | 430 | numberList.Add(-0.6805); |
431 | numberList.Add(548.5); | 431 | numberList.Add(548.5); |
432 | numberList.Add(2.0005); | 432 | numberList.Add(2.0005); |
433 | numberList.Add(349485435.6805); | 433 | numberList.Add(349485435.6805); |
434 | numberList.Add(-548.5); | 434 | numberList.Add(-548.5); |
435 | numberList.Add(-2.0005); | 435 | numberList.Add(-2.0005); |
436 | numberList.Add(-349485435.6805); | 436 | numberList.Add(-349485435.6805); |
437 | 437 | ||
438 | LSL_Types.LSLFloat testFloat; | 438 | LSL_Types.LSLFloat testFloat; |
439 | double testNumber; | 439 | double testNumber; |
440 | 440 | ||
441 | foreach(double number in numberList) | 441 | foreach(double number in numberList) |
442 | { | 442 | { |
443 | testFloat = new LSL_Types.LSLFloat(number); | 443 | testFloat = new LSL_Types.LSLFloat(number); |
444 | 444 | ||
445 | testNumber = testFloat++; | 445 | testNumber = testFloat++; |
446 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | 446 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); |
447 | 447 | ||
448 | testNumber = testFloat; | 448 | testNumber = testFloat; |
449 | Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance)); | 449 | Assert.That(testNumber, new DoubleToleranceConstraint(number + 1.0, _lowPrecisionTolerance)); |
450 | 450 | ||
451 | testNumber = ++testFloat; | 451 | testNumber = ++testFloat; |
452 | Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance)); | 452 | Assert.That(testNumber, new DoubleToleranceConstraint(number + 2.0, _lowPrecisionTolerance)); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | /// <summary> | 456 | /// <summary> |
457 | /// Tests the decrement operator. | 457 | /// Tests the decrement operator. |
458 | /// </summary> | 458 | /// </summary> |
459 | [Test] | 459 | [Test] |
460 | public void TestDecrementOperator() | 460 | public void TestDecrementOperator() |
461 | { | 461 | { |
462 | // A bunch of numbers to test with. | 462 | // A bunch of numbers to test with. |
463 | List<double> numberList = new List<double>(); | 463 | List<double> numberList = new List<double>(); |
464 | numberList.Add(2.0); | 464 | numberList.Add(2.0); |
465 | numberList.Add(-2.0); | 465 | numberList.Add(-2.0); |
466 | numberList.Add(1.0); | 466 | numberList.Add(1.0); |
467 | numberList.Add(-1.0); | 467 | numberList.Add(-1.0); |
468 | numberList.Add(0.0); | 468 | numberList.Add(0.0); |
469 | numberList.Add(999999999.0); | 469 | numberList.Add(999999999.0); |
470 | numberList.Add(-99999999.0); | 470 | numberList.Add(-99999999.0); |
471 | numberList.Add(0.5); | 471 | numberList.Add(0.5); |
472 | numberList.Add(0.0005); | 472 | numberList.Add(0.0005); |
473 | numberList.Add(0.6805); | 473 | numberList.Add(0.6805); |
474 | numberList.Add(-0.5); | 474 | numberList.Add(-0.5); |
475 | numberList.Add(-0.0005); | 475 | numberList.Add(-0.0005); |
476 | numberList.Add(-0.6805); | 476 | numberList.Add(-0.6805); |
477 | numberList.Add(548.5); | 477 | numberList.Add(548.5); |
478 | numberList.Add(2.0005); | 478 | numberList.Add(2.0005); |
479 | numberList.Add(349485435.6805); | 479 | numberList.Add(349485435.6805); |
480 | numberList.Add(-548.5); | 480 | numberList.Add(-548.5); |
481 | numberList.Add(-2.0005); | 481 | numberList.Add(-2.0005); |
482 | numberList.Add(-349485435.6805); | 482 | numberList.Add(-349485435.6805); |
483 | 483 | ||
484 | LSL_Types.LSLFloat testFloat; | 484 | LSL_Types.LSLFloat testFloat; |
485 | double testNumber; | 485 | double testNumber; |
486 | 486 | ||
487 | foreach(double number in numberList) | 487 | foreach(double number in numberList) |
488 | { | 488 | { |
489 | testFloat = new LSL_Types.LSLFloat(number); | 489 | testFloat = new LSL_Types.LSLFloat(number); |
490 | 490 | ||
491 | testNumber = testFloat--; | 491 | testNumber = testFloat--; |
492 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | 492 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); |
493 | 493 | ||
494 | testNumber = testFloat; | 494 | testNumber = testFloat; |
495 | Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance)); | 495 | Assert.That(testNumber, new DoubleToleranceConstraint(number - 1.0, _lowPrecisionTolerance)); |
496 | 496 | ||
497 | testNumber = --testFloat; | 497 | testNumber = --testFloat; |
498 | Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance)); | 498 | Assert.That(testNumber, new DoubleToleranceConstraint(number - 2.0, _lowPrecisionTolerance)); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | /// <summary> | 502 | /// <summary> |
503 | /// Tests LSLFloat is correctly cast implicitly to double. | 503 | /// Tests LSLFloat is correctly cast implicitly to double. |
504 | /// </summary> | 504 | /// </summary> |
505 | [Test] | 505 | [Test] |
506 | public void TestImplicitCastLSLFloatToDouble() | 506 | public void TestImplicitCastLSLFloatToDouble() |
507 | { | 507 | { |
508 | // A bunch of numbers to test with. | 508 | // A bunch of numbers to test with. |
509 | List<double> numberList = new List<double>(); | 509 | List<double> numberList = new List<double>(); |
510 | numberList.Add(2.0); | 510 | numberList.Add(2.0); |
511 | numberList.Add(-2.0); | 511 | numberList.Add(-2.0); |
512 | numberList.Add(1.0); | 512 | numberList.Add(1.0); |
513 | numberList.Add(-1.0); | 513 | numberList.Add(-1.0); |
514 | numberList.Add(0.0); | 514 | numberList.Add(0.0); |
515 | numberList.Add(999999999.0); | 515 | numberList.Add(999999999.0); |
516 | numberList.Add(-99999999.0); | 516 | numberList.Add(-99999999.0); |
517 | numberList.Add(0.5); | 517 | numberList.Add(0.5); |
518 | numberList.Add(0.0005); | 518 | numberList.Add(0.0005); |
519 | numberList.Add(0.6805); | 519 | numberList.Add(0.6805); |
520 | numberList.Add(-0.5); | 520 | numberList.Add(-0.5); |
521 | numberList.Add(-0.0005); | 521 | numberList.Add(-0.0005); |
522 | numberList.Add(-0.6805); | 522 | numberList.Add(-0.6805); |
523 | numberList.Add(548.5); | 523 | numberList.Add(548.5); |
524 | numberList.Add(2.0005); | 524 | numberList.Add(2.0005); |
525 | numberList.Add(349485435.6805); | 525 | numberList.Add(349485435.6805); |
526 | numberList.Add(-548.5); | 526 | numberList.Add(-548.5); |
527 | numberList.Add(-2.0005); | 527 | numberList.Add(-2.0005); |
528 | numberList.Add(-349485435.6805); | 528 | numberList.Add(-349485435.6805); |
529 | 529 | ||
530 | double testNumber; | 530 | double testNumber; |
531 | LSL_Types.LSLFloat testFloat; | 531 | LSL_Types.LSLFloat testFloat; |
532 | 532 | ||
533 | foreach(double number in numberList) | 533 | foreach(double number in numberList) |
534 | { | 534 | { |
535 | testFloat = new LSL_Types.LSLFloat(number); | 535 | testFloat = new LSL_Types.LSLFloat(number); |
536 | testNumber = testFloat; | 536 | testNumber = testFloat; |
537 | 537 | ||
538 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); | 538 | Assert.That(testNumber, new DoubleToleranceConstraint(number, _lowPrecisionTolerance)); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | /// <summary> | 542 | /// <summary> |
543 | /// Tests LSLFloat.ToString(). | 543 | /// Tests LSLFloat.ToString(). |
544 | /// </summary> | 544 | /// </summary> |
545 | [Test] | 545 | [Test] |
546 | public void TestToString() | 546 | public void TestToString() |
547 | { | 547 | { |
548 | // A bunch of numbers to test with. | 548 | // A bunch of numbers to test with. |
549 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); | 549 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); |
550 | numberSet.Add(2.0, "2.000000"); | 550 | numberSet.Add(2.0, "2.000000"); |
551 | numberSet.Add(-2.0, "-2.000000"); | 551 | numberSet.Add(-2.0, "-2.000000"); |
552 | numberSet.Add(1.0, "1.000000"); | 552 | numberSet.Add(1.0, "1.000000"); |
553 | numberSet.Add(-1.0, "-1.000000"); | 553 | numberSet.Add(-1.0, "-1.000000"); |
554 | numberSet.Add(0.0, "0.000000"); | 554 | numberSet.Add(0.0, "0.000000"); |
555 | numberSet.Add(999999999.0, "999999999.000000"); | 555 | numberSet.Add(999999999.0, "999999999.000000"); |
556 | numberSet.Add(-99999999.0, "-99999999.000000"); | 556 | numberSet.Add(-99999999.0, "-99999999.000000"); |
557 | numberSet.Add(0.5, "0.500000"); | 557 | numberSet.Add(0.5, "0.500000"); |
558 | numberSet.Add(0.0005, "0.000500"); | 558 | numberSet.Add(0.0005, "0.000500"); |
559 | numberSet.Add(0.6805, "0.680500"); | 559 | numberSet.Add(0.6805, "0.680500"); |
560 | numberSet.Add(-0.5, "-0.500000"); | 560 | numberSet.Add(-0.5, "-0.500000"); |
561 | numberSet.Add(-0.0005, "-0.000500"); | 561 | numberSet.Add(-0.0005, "-0.000500"); |
562 | numberSet.Add(-0.6805, "-0.680500"); | 562 | numberSet.Add(-0.6805, "-0.680500"); |
563 | numberSet.Add(548.5, "548.500000"); | 563 | numberSet.Add(548.5, "548.500000"); |
564 | numberSet.Add(2.0005, "2.000500"); | 564 | numberSet.Add(2.0005, "2.000500"); |
565 | numberSet.Add(349485435.6805, "349485435.680500"); | 565 | numberSet.Add(349485435.6805, "349485435.680500"); |
566 | numberSet.Add(-548.5, "-548.500000"); | 566 | numberSet.Add(-548.5, "-548.500000"); |
567 | numberSet.Add(-2.0005, "-2.000500"); | 567 | numberSet.Add(-2.0005, "-2.000500"); |
568 | numberSet.Add(-349485435.6805, "-349485435.680500"); | 568 | numberSet.Add(-349485435.6805, "-349485435.680500"); |
569 | 569 | ||
570 | LSL_Types.LSLFloat testFloat; | 570 | LSL_Types.LSLFloat testFloat; |
571 | 571 | ||
572 | foreach(KeyValuePair<double, string> number in numberSet) | 572 | foreach(KeyValuePair<double, string> number in numberSet) |
573 | { | 573 | { |
574 | testFloat = new LSL_Types.LSLFloat(number.Key); | 574 | testFloat = new LSL_Types.LSLFloat(number.Key); |
575 | Assert.AreEqual(number.Value, testFloat.ToString()); | 575 | Assert.AreEqual(number.Value, testFloat.ToString()); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | } | 578 | } |
579 | } | 579 | } |
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs index 615c045..83c7e77 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/LSL_TypesTestLSLString.cs | |||
@@ -1,112 +1,112 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenSim.Tests.Common; | 30 | using OpenSim.Tests.Common; |
31 | using OpenSim.Region.ScriptEngine.Common; | 31 | using OpenSim.Region.ScriptEngine.Common; |
32 | 32 | ||
33 | namespace OpenSim.Region.ScriptEngine.Common.Tests | 33 | namespace OpenSim.Region.ScriptEngine.Common.Tests |
34 | { | 34 | { |
35 | [TestFixture] | 35 | [TestFixture] |
36 | public class LSL_TypesTestLSLString | 36 | public class LSL_TypesTestLSLString |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// Tests constructing a LSLString from an LSLFloat. | 39 | /// Tests constructing a LSLString from an LSLFloat. |
40 | /// </summary> | 40 | /// </summary> |
41 | [Test] | 41 | [Test] |
42 | public void TestConstructFromLSLFloat() | 42 | public void TestConstructFromLSLFloat() |
43 | { | 43 | { |
44 | // The numbers we test for. | 44 | // The numbers we test for. |
45 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); | 45 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); |
46 | numberSet.Add(2, "2.000000"); | 46 | numberSet.Add(2, "2.000000"); |
47 | numberSet.Add(-2, "-2.000000"); | 47 | numberSet.Add(-2, "-2.000000"); |
48 | numberSet.Add(0, "0.000000"); | 48 | numberSet.Add(0, "0.000000"); |
49 | numberSet.Add(1, "1.000000"); | 49 | numberSet.Add(1, "1.000000"); |
50 | numberSet.Add(-1, "-1.000000"); | 50 | numberSet.Add(-1, "-1.000000"); |
51 | numberSet.Add(999999999, "999999999.000000"); | 51 | numberSet.Add(999999999, "999999999.000000"); |
52 | numberSet.Add(-99999999, "-99999999.000000"); | 52 | numberSet.Add(-99999999, "-99999999.000000"); |
53 | numberSet.Add(0.5, "0.500000"); | 53 | numberSet.Add(0.5, "0.500000"); |
54 | numberSet.Add(0.0005, "0.000500"); | 54 | numberSet.Add(0.0005, "0.000500"); |
55 | numberSet.Add(0.6805, "0.680500"); | 55 | numberSet.Add(0.6805, "0.680500"); |
56 | numberSet.Add(-0.5, "-0.500000"); | 56 | numberSet.Add(-0.5, "-0.500000"); |
57 | numberSet.Add(-0.0005, "-0.000500"); | 57 | numberSet.Add(-0.0005, "-0.000500"); |
58 | numberSet.Add(-0.6805, "-0.680500"); | 58 | numberSet.Add(-0.6805, "-0.680500"); |
59 | numberSet.Add(548.5, "548.500000"); | 59 | numberSet.Add(548.5, "548.500000"); |
60 | numberSet.Add(2.0005, "2.000500"); | 60 | numberSet.Add(2.0005, "2.000500"); |
61 | numberSet.Add(349485435.6805, "349485435.680500"); | 61 | numberSet.Add(349485435.6805, "349485435.680500"); |
62 | numberSet.Add(-548.5, "-548.500000"); | 62 | numberSet.Add(-548.5, "-548.500000"); |
63 | numberSet.Add(-2.0005, "-2.000500"); | 63 | numberSet.Add(-2.0005, "-2.000500"); |
64 | numberSet.Add(-349485435.6805, "-349485435.680500"); | 64 | numberSet.Add(-349485435.6805, "-349485435.680500"); |
65 | 65 | ||
66 | LSL_Types.LSLString testString; | 66 | LSL_Types.LSLString testString; |
67 | 67 | ||
68 | foreach(KeyValuePair<double, string> number in numberSet) | 68 | foreach(KeyValuePair<double, string> number in numberSet) |
69 | { | 69 | { |
70 | testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key)); | 70 | testString = new LSL_Types.LSLString(new LSL_Types.LSLFloat(number.Key)); |
71 | Assert.AreEqual(number.Value, testString.m_string); | 71 | Assert.AreEqual(number.Value, testString.m_string); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Tests constructing a LSLString from an LSLFloat. | 76 | /// Tests constructing a LSLString from an LSLFloat. |
77 | /// </summary> | 77 | /// </summary> |
78 | [Test] | 78 | [Test] |
79 | public void TestExplicitCastLSLFloatToLSLString() | 79 | public void TestExplicitCastLSLFloatToLSLString() |
80 | { | 80 | { |
81 | // The numbers we test for. | 81 | // The numbers we test for. |
82 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); | 82 | Dictionary<double, string> numberSet = new Dictionary<double, string>(); |
83 | numberSet.Add(2, "2.000000"); | 83 | numberSet.Add(2, "2.000000"); |
84 | numberSet.Add(-2, "-2.000000"); | 84 | numberSet.Add(-2, "-2.000000"); |
85 | numberSet.Add(0, "0.000000"); | 85 | numberSet.Add(0, "0.000000"); |
86 | numberSet.Add(1, "1.000000"); | 86 | numberSet.Add(1, "1.000000"); |
87 | numberSet.Add(-1, "-1.000000"); | 87 | numberSet.Add(-1, "-1.000000"); |
88 | numberSet.Add(999999999, "999999999.000000"); | 88 | numberSet.Add(999999999, "999999999.000000"); |
89 | numberSet.Add(-99999999, "-99999999.000000"); | 89 | numberSet.Add(-99999999, "-99999999.000000"); |
90 | numberSet.Add(0.5, "0.500000"); | 90 | numberSet.Add(0.5, "0.500000"); |
91 | numberSet.Add(0.0005, "0.000500"); | 91 | numberSet.Add(0.0005, "0.000500"); |
92 | numberSet.Add(0.6805, "0.680500"); | 92 | numberSet.Add(0.6805, "0.680500"); |
93 | numberSet.Add(-0.5, "-0.500000"); | 93 | numberSet.Add(-0.5, "-0.500000"); |
94 | numberSet.Add(-0.0005, "-0.000500"); | 94 | numberSet.Add(-0.0005, "-0.000500"); |
95 | numberSet.Add(-0.6805, "-0.680500"); | 95 | numberSet.Add(-0.6805, "-0.680500"); |
96 | numberSet.Add(548.5, "548.500000"); | 96 | numberSet.Add(548.5, "548.500000"); |
97 | numberSet.Add(2.0005, "2.000500"); | 97 | numberSet.Add(2.0005, "2.000500"); |
98 | numberSet.Add(349485435.6805, "349485435.680500"); | 98 | numberSet.Add(349485435.6805, "349485435.680500"); |
99 | numberSet.Add(-548.5, "-548.500000"); | 99 | numberSet.Add(-548.5, "-548.500000"); |
100 | numberSet.Add(-2.0005, "-2.000500"); | 100 | numberSet.Add(-2.0005, "-2.000500"); |
101 | numberSet.Add(-349485435.6805, "-349485435.680500"); | 101 | numberSet.Add(-349485435.6805, "-349485435.680500"); |
102 | 102 | ||
103 | LSL_Types.LSLString testString; | 103 | LSL_Types.LSLString testString; |
104 | 104 | ||
105 | foreach(KeyValuePair<double, string> number in numberSet) | 105 | foreach(KeyValuePair<double, string> number in numberSet) |
106 | { | 106 | { |
107 | testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key); | 107 | testString = (LSL_Types.LSLString) new LSL_Types.LSLFloat(number.Key); |
108 | Assert.AreEqual(number.Value, testString.m_string); | 108 | Assert.AreEqual(number.Value, testString.m_string); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |