diff options
author | Mike Mazur | 2008-07-28 07:46:53 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-28 07:46:53 +0000 |
commit | f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d (patch) | |
tree | 93ca486045152bb3d60903e395b84ab3fe51d701 /OpenSim/Tests | |
parent | -implement LSLString -> Quaternion explicit cast (diff) | |
download | opensim-SC_OLD-f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d.zip opensim-SC_OLD-f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d.tar.gz opensim-SC_OLD-f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d.tar.bz2 opensim-SC_OLD-f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d.tar.xz |
When casting strings to int, use double.Parse() as strings may be floats. With
this commit, issue 1822 should be fixed.
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLInteger.cs | 43 | ||||
-rw-r--r-- | OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLInteger.cs | 43 |
2 files changed, 84 insertions, 2 deletions
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLInteger.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLInteger.cs index 08f80d3..3f01d09 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLInteger.cs | |||
@@ -36,6 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
36 | public class LSL_TypesTestLSLInteger | 36 | public class LSL_TypesTestLSLInteger |
37 | { | 37 | { |
38 | private Dictionary<double, int> m_doubleIntSet; | 38 | private Dictionary<double, int> m_doubleIntSet; |
39 | private Dictionary<string, int> m_stringIntSet; | ||
39 | 40 | ||
40 | /// <summary> | 41 | /// <summary> |
41 | /// Sets up dictionaries and arrays used in the tests. | 42 | /// Sets up dictionaries and arrays used in the tests. |
@@ -51,10 +52,20 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
51 | m_doubleIntSet.Add(-1.0, -1); | 52 | m_doubleIntSet.Add(-1.0, -1); |
52 | m_doubleIntSet.Add(999999999.0, 999999999); | 53 | m_doubleIntSet.Add(999999999.0, 999999999); |
53 | m_doubleIntSet.Add(-99999999.0, -99999999); | 54 | m_doubleIntSet.Add(-99999999.0, -99999999); |
55 | |||
56 | m_stringIntSet = new Dictionary<string, int>(); | ||
57 | m_stringIntSet.Add("2", 2); | ||
58 | m_stringIntSet.Add("-2", -2); | ||
59 | m_stringIntSet.Add("0", 0); | ||
60 | m_stringIntSet.Add("1", 1); | ||
61 | m_stringIntSet.Add("-1", -1); | ||
62 | m_stringIntSet.Add("123.9", 123); | ||
63 | m_stringIntSet.Add("999999999", 999999999); | ||
64 | m_stringIntSet.Add("-99999999", -99999999); | ||
54 | } | 65 | } |
55 | 66 | ||
56 | /// <summary> | 67 | /// <summary> |
57 | /// Tests LSLInteger is correctly cast explicitly to LSLFloat. | 68 | /// Tests LSLFloat is correctly cast explicitly to LSLInteger. |
58 | /// </summary> | 69 | /// </summary> |
59 | [Test] | 70 | [Test] |
60 | public void TestExplicitCastLSLFloatToLSLInteger() | 71 | public void TestExplicitCastLSLFloatToLSLInteger() |
@@ -67,5 +78,35 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests | |||
67 | Assert.AreEqual(testInteger.value, number.Value); | 78 | Assert.AreEqual(testInteger.value, number.Value); |
68 | } | 79 | } |
69 | } | 80 | } |
81 | |||
82 | /// <summary> | ||
83 | /// Tests string is correctly cast explicitly to LSLInteger. | ||
84 | /// </summary> | ||
85 | [Test] | ||
86 | public void TestExplicitCastStringToLSLInteger() | ||
87 | { | ||
88 | LSL_Types.LSLInteger testInteger; | ||
89 | |||
90 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | ||
91 | { | ||
92 | testInteger = (LSL_Types.LSLInteger) number.Key; | ||
93 | Assert.AreEqual(testInteger.value, number.Value); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Tests LSLString is correctly cast explicitly to LSLInteger. | ||
99 | /// </summary> | ||
100 | [Test] | ||
101 | public void TestExplicitCastLSLStringToLSLInteger() | ||
102 | { | ||
103 | LSL_Types.LSLInteger testInteger; | ||
104 | |||
105 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | ||
106 | { | ||
107 | testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLString(number.Key); | ||
108 | Assert.AreEqual(testInteger.value, number.Value); | ||
109 | } | ||
110 | } | ||
70 | } | 111 | } |
71 | } | 112 | } |
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLInteger.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLInteger.cs index a4e7bbc..d158084 100644 --- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Shared/LSL_TypesTestLSLInteger.cs | |||
@@ -36,6 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
36 | public class LSL_TypesTestLSLInteger | 36 | public class LSL_TypesTestLSLInteger |
37 | { | 37 | { |
38 | private Dictionary<double, int> m_doubleIntSet; | 38 | private Dictionary<double, int> m_doubleIntSet; |
39 | private Dictionary<string, int> m_stringIntSet; | ||
39 | 40 | ||
40 | /// <summary> | 41 | /// <summary> |
41 | /// Sets up dictionaries and arrays used in the tests. | 42 | /// Sets up dictionaries and arrays used in the tests. |
@@ -51,10 +52,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
51 | m_doubleIntSet.Add(-1.0, -1); | 52 | m_doubleIntSet.Add(-1.0, -1); |
52 | m_doubleIntSet.Add(999999999.0, 999999999); | 53 | m_doubleIntSet.Add(999999999.0, 999999999); |
53 | m_doubleIntSet.Add(-99999999.0, -99999999); | 54 | m_doubleIntSet.Add(-99999999.0, -99999999); |
55 | |||
56 | m_stringIntSet = new Dictionary<string, int>(); | ||
57 | m_stringIntSet.Add("2", 2); | ||
58 | m_stringIntSet.Add("-2", -2); | ||
59 | m_stringIntSet.Add("0", 0); | ||
60 | m_stringIntSet.Add("1", 1); | ||
61 | m_stringIntSet.Add("-1", -1); | ||
62 | m_stringIntSet.Add("123.9", 123); | ||
63 | m_stringIntSet.Add("999999999", 999999999); | ||
64 | m_stringIntSet.Add("-99999999", -99999999); | ||
54 | } | 65 | } |
55 | 66 | ||
56 | /// <summary> | 67 | /// <summary> |
57 | /// Tests LSLInteger is correctly cast explicitly to LSLFloat. | 68 | /// Tests LSLFloat is correctly cast explicitly to LSLInteger. |
58 | /// </summary> | 69 | /// </summary> |
59 | [Test] | 70 | [Test] |
60 | public void TestExplicitCastLSLFloatToLSLInteger() | 71 | public void TestExplicitCastLSLFloatToLSLInteger() |
@@ -67,5 +78,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
67 | Assert.AreEqual(testInteger.value, number.Value); | 78 | Assert.AreEqual(testInteger.value, number.Value); |
68 | } | 79 | } |
69 | } | 80 | } |
81 | |||
82 | /// <summary> | ||
83 | /// Tests string is correctly cast explicitly to LSLInteger. | ||
84 | /// </summary> | ||
85 | [Test] | ||
86 | public void TestExplicitCastStringToLSLInteger() | ||
87 | { | ||
88 | LSL_Types.LSLInteger testInteger; | ||
89 | |||
90 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | ||
91 | { | ||
92 | testInteger = (LSL_Types.LSLInteger) number.Key; | ||
93 | Assert.AreEqual(testInteger.value, number.Value); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Tests LSLString is correctly cast explicitly to LSLInteger. | ||
99 | /// </summary> | ||
100 | [Test] | ||
101 | public void TestExplicitCastLSLStringToLSLInteger() | ||
102 | { | ||
103 | LSL_Types.LSLInteger testInteger; | ||
104 | |||
105 | foreach (KeyValuePair<string, int> number in m_stringIntSet) | ||
106 | { | ||
107 | testInteger = (LSL_Types.LSLInteger) new LSL_Types.LSLString(number.Key); | ||
108 | Assert.AreEqual(testInteger.value, number.Value); | ||
109 | } | ||
110 | } | ||
70 | } | 111 | } |
71 | } | 112 | } |