From 947242f4764b8d98fe860d3c18bcea709aea777f Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 5 Sep 2008 23:26:35 +0000 Subject: Mantis#2126. Thank you kindly, Ralphos for a patch that addresses: Types extracted from a LSL_Types.list have to be down-cast initially to the exact type of value type object that the Object actually is. This would make for very cumbersome, ugly code when extracting list parameter items in ll functions where a few implicit conversions should be applied such as key -> LSLString and LSLInteger -> LSLFloat (but not LSLFloat -> LSLInteger). This patch adds a set of GetXXXItem member functions to the LLS_Type.list class, where XXX is the name of the LSL_Type to be extracted: LSLFLoat, LSLInteger etc. All take a single, int parameter that is the item number to be extracted. --- .../ScriptEngine/Shared/LSL_TypesTestList.cs | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'OpenSim/Tests/Region') diff --git a/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs b/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs index 9e8d716..ca59c97 100644 --- a/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs +++ b/OpenSim/Tests/Region/ScriptEngine/Shared/LSL_TypesTestList.cs @@ -157,6 +157,105 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]); } +//==================================================================================== + /// + /// Tests GetLSLIntegerItem for LSLInteger item. + /// + [Test] + public void TestGetLSLIntegerItemForLSLIntegerItem() + { + LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetLSLIntegerItem(0)); + } + + /// + /// Tests GetLSLFloatItem for LSLFloat item. + /// + [Test] + public void TestGetLSLFloatItemForLSLFloatItem() + { + LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetLSLFloatItem(0)); + } + + /// + /// Tests GetLSLFloatItem for LSLInteger item. + /// + [Test] + public void TestGetLSLFloatItemForLSLIntegerItem() + { + LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); + LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); + } + + /// + /// Tests GetLSLStringItem for LSLString item. + /// + [Test] + public void TestGetLSLStringItemForLSLStringItem() + { + LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all"); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetLSLStringItem(0)); + } + + /// + /// Tests GetLSLStringItem for key item. + /// + [Test] + public void TestGetLSLStringItemForKeyItem() + { + LSL_Types.key testValue + = new LSL_Types.key("98000000-0000-2222-3333-100000001000"); + LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testStringValue, testList.GetLSLStringItem(0)); + } + + /// + /// Tests GetVector3Item for Vector3 item. + /// + [Test] + public void TestGetVector3ItemForVector3Item() + { + LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetVector3Item(0)); + } + /// + /// Tests GetQuaternionItem for Quaternion item. + /// + [Test] + public void TestGetQuaternionItemForQuaternionItem() + { + LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetQuaternionItem(0)); + } + + /// + /// Tests GetKeyItem for key item. + /// + [Test] + public void TestGetKeyItemForKeyItem() + { + LSL_Types.key testValue + = new LSL_Types.key("00000000-0000-2222-3333-100000001012"); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testValue, testList.GetKeyItem(0)); + } } } -- cgit v1.1