- Added tests for the Design namespace

- Fixed all ToString methods
- Fixed some GetHashcode methods
This commit is contained in:
SND\GinieDp_cp 2011-11-16 22:35:53 +00:00
parent 8059966fef
commit 1dafda1067
16 changed files with 358 additions and 63 deletions

View File

@ -58,6 +58,7 @@
<Compile Include="ContentPipeline\Helper\Nullable.cs" /> <Compile Include="ContentPipeline\Helper\Nullable.cs" />
<Compile Include="DataFactory.cs" /> <Compile Include="DataFactory.cs" />
<Compile Include="Input\GamePadDPadTest.cs" /> <Compile Include="Input\GamePadDPadTest.cs" />
<Compile Include="Design\TypeConverterTest.cs" />
<Compile Include="IntegrationTest.cs" /> <Compile Include="IntegrationTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" /> <Compile Include="Strukturen\BoundingBoxTest.cs" />

View File

@ -0,0 +1,218 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using NUnit.Framework;
#endregion // Using Statements
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
using XnaVector3 = Microsoft.Xna.Framework.Vector3;
using AnxVector3 = ANX.Framework.Vector3;
namespace ANX.Framework.TestCenter.Design
{
[TestFixture]
public class TypeConverterTest
{
[Test]
public void ConvertVector2Test()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.Vector2Converter();
var anxConverter = new ANX.Framework.Design.Vector2Converter();
var xnaObject = new Microsoft.Xna.Framework.Vector2(1, 2);
var anxObject = new ANX.Framework.Vector2(1, 2);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
Assert.AreEqual(anxObject, anxConverter.ConvertFrom(xnaConverter.ConvertToString(xnaObject)));
}
[Test]
public void ConvertVector3Test()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.Vector3Converter();
var anxConverter = new ANX.Framework.Design.Vector3Converter();
var xnaObject = new Microsoft.Xna.Framework.Vector3(1, 2, 3);
var anxObject = new ANX.Framework.Vector3(1, 2, 3);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
Assert.AreEqual(anxObject, anxConverter.ConvertFrom(xnaConverter.ConvertToString(xnaObject)));
}
[Test]
public void ConvertVector4Test()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.Vector4Converter();
var anxConverter = new ANX.Framework.Design.Vector4Converter();
var xnaObject = new Microsoft.Xna.Framework.Vector4(1, 2, 3, 4);
var anxObject = new ANX.Framework.Vector4(1, 2, 3, 4);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
Assert.AreEqual(anxObject, anxConverter.ConvertFrom(xnaConverter.ConvertToString(xnaObject)));
}
[Test]
public void ConvertQuaternionTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.QuaternionConverter();
var anxConverter = new ANX.Framework.Design.QuaternionConverter();
var xnaObject = new Microsoft.Xna.Framework.Quaternion(1, 2, 3, 4);
var anxObject = new ANX.Framework.Quaternion(1, 2, 3, 4);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
Assert.AreEqual(anxObject, anxConverter.ConvertFrom(xnaConverter.ConvertToString(xnaObject)));
}
[Test]
public void ConvertRectangleTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.RectangleConverter();
var anxConverter = new ANX.Framework.Design.RectangleConverter();
var xnaObject = new Microsoft.Xna.Framework.Rectangle(1, 2, 3, 4);
var anxObject = new ANX.Framework.Rectangle(1, 2, 3, 4);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// rectangle cannot convert from string
}
[Test]
public void ConvertRayTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.RayConverter();
var anxConverter = new ANX.Framework.Design.RayConverter();
var xnaObject = new Microsoft.Xna.Framework.Ray(new XnaVector3(1, 2, 3), new XnaVector3(4, 5, 6));
var anxObject = new ANX.Framework.Ray(new AnxVector3(1, 2, 3), new AnxVector3(4, 5, 6));
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// ray cannot convert from string
}
[Test]
public void ConvertPointTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.PointConverter();
var anxConverter = new ANX.Framework.Design.PointConverter();
var xnaObject = new Microsoft.Xna.Framework.Point(1, 2);
var anxObject = new ANX.Framework.Point(1, 2);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
Assert.AreEqual(anxObject, anxConverter.ConvertFrom(xnaConverter.ConvertToString(xnaObject)));
}
[Test]
public void ConvertPlaneTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.PlaneConverter();
var anxConverter = new ANX.Framework.Design.PlaneConverter();
var xnaObject = new Microsoft.Xna.Framework.Plane(new XnaVector3(1, 2, 3), 4);
var anxObject = new ANX.Framework.Plane(new AnxVector3(1, 2, 3), 4);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// plane cannot convert from string
}
[Test]
public void ConvertBoundingBoxTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.BoundingBoxConverter();
var anxConverter = new ANX.Framework.Design.BoundingBoxConverter();
var xnaObject = new Microsoft.Xna.Framework.BoundingBox(new XnaVector3(1, 2, 3), new XnaVector3(4, 5, 6));
var anxObject = new ANX.Framework.BoundingBox(new AnxVector3(1, 2, 3), new AnxVector3(4, 5, 6));
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// plane cannot convert from string
}
[Test]
public void ConvertBoundingSphereTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.BoundingSphereConverter();
var anxConverter = new ANX.Framework.Design.BoundingSphereConverter();
var xnaObject = new Microsoft.Xna.Framework.BoundingSphere(new XnaVector3(1, 2, 3), 4);
var anxObject = new ANX.Framework.BoundingSphere(new AnxVector3(1, 2, 3), 4);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// plane cannot convert from string
}
[Test]
public void ConvertMatrixTest()
{
var xnaConverter = new Microsoft.Xna.Framework.Design.MatrixConverter();
var anxConverter = new ANX.Framework.Design.MatrixConverter();
var xnaObject = new Microsoft.Xna.Framework.Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
var anxObject = new ANX.Framework.Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Assert.AreEqual(xnaConverter.ConvertToString(xnaObject), anxConverter.ConvertToString(anxObject));
// matrix cannot convert from string
}
[Test]
public void ConvertBoundingFrustumTest()
{
var xnaObject = new Microsoft.Xna.Framework.BoundingFrustum(new Microsoft.Xna.Framework.Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
var anxObject = new ANX.Framework.BoundingFrustum(new ANX.Framework.Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
Assert.AreEqual(xnaObject.ToString(), anxObject.ToString());
}
}
}

View File

@ -352,7 +352,7 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
throw new Exception("method has not yet been implemented"); return this.Min.GetHashCode() + this.Max.GetHashCode();
} }
public bool Intersects(BoundingBox box) public bool Intersects(BoundingBox box)
@ -567,7 +567,12 @@ namespace ANX.Framework
public override string ToString() public override string ToString()
{ {
return "Min:" + Min.ToString() + " Max:" + Max.ToString(); var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{Min:{0} Max:{1}}}", new object[]
{
this.Min.ToString(),
this.Max.ToString()
});
} }
#endregion #endregion

View File

@ -566,7 +566,7 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
throw new NotImplementedException(); return this.matrix.GetHashCode();
} }
public bool Intersects(BoundingBox box) public bool Intersects(BoundingBox box)
@ -810,21 +810,16 @@ namespace ANX.Framework
//source: monoxna //source: monoxna
public override string ToString() public override string ToString()
{ {
StringBuilder sb = new StringBuilder(256); var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
sb.Append("{Near:"); return string.Format(currentCulture, "{{Near:{0} Far:{1} Left:{2} Right:{3} Top:{4} Bottom:{5}}}", new object[]
sb.Append(this.near.ToString()); {
sb.Append(" Far:"); this.Near.ToString(),
sb.Append(this.far.ToString()); this.Far.ToString(),
sb.Append(" Left:"); this.Left.ToString(),
sb.Append(this.left.ToString()); this.Right.ToString(),
sb.Append(" Right:"); this.Top.ToString(),
sb.Append(this.right.ToString()); this.Bottom.ToString()
sb.Append(" Top:"); });
sb.Append(this.top.ToString());
sb.Append(" Bottom:");
sb.Append(this.bottom.ToString());
sb.Append("}");
return sb.ToString();
} }
#endregion #endregion

View File

@ -263,7 +263,7 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
throw new NotImplementedException(); return this.Radius.GetHashCode() + this.Center.GetHashCode();
} }
public bool Intersects(BoundingBox box) public bool Intersects(BoundingBox box)
@ -455,7 +455,12 @@ namespace ANX.Framework
public override string ToString() public override string ToString()
{ {
return "Center:" + Center.ToString() + " Radius:" + Radius.ToString(); var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{Center:{0} Radius:{1}}}", new object[]
{
this.Center.ToString(),
this.Radius.ToString(currentCulture)
});
} }
#endregion #endregion

View File

@ -73,10 +73,13 @@ namespace ANX.Framework.Design
string separator = "; "; string separator = "; ";
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
foreach (var item in values) for (int i = 0; i < values.Length; i++)
{ {
builder.Append(converter.ConvertToString(context, culture, item)); builder.Append(converter.ConvertToString(context, culture, values[i]));
builder.Append(separator); if (i < values.Length - 1)
{
builder.Append(separator);
}
} }
return builder.ToString(); return builder.ToString();
} }

View File

@ -20,11 +20,6 @@ namespace ANX.Framework.Design
supportStringConvert = false; supportStringConvert = false;
} }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{ {
if (destinationType == null) if (destinationType == null)

View File

@ -13,16 +13,7 @@ namespace ANX.Framework.Design
public RectangleConverter() public RectangleConverter()
{ {
base.propertyDescriptions = MathTypeConverter.CreateFieldDescriptor<Rectangle>("X", "Y", "Width", "Height"); base.propertyDescriptions = MathTypeConverter.CreateFieldDescriptor<Rectangle>("X", "Y", "Width", "Height");
} supportStringConvert = false;
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
int[] values = MathTypeConverter.ConvertFromString<int>(context, culture, value as String);
if (values != null && values.Length == 4)
{
return new Rectangle(values[0], values[1], values[2], values[3]);
}
return base.ConvertFrom(context, culture, value);
} }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
@ -35,10 +26,6 @@ namespace ANX.Framework.Design
{ {
Rectangle instance = (Rectangle)value; Rectangle instance = (Rectangle)value;
if (destinationType == typeof(string))
{
return MathTypeConverter.ConvertToString<int>(context, culture, new int[] { instance.X, instance.Y, instance.Width, instance.Height });
}
if (destinationType == typeof(InstanceDescriptor)) if (destinationType == typeof(InstanceDescriptor))
{ {
var constructor = typeof(Rectangle).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) }); var constructor = typeof(Rectangle).GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) });

View File

@ -1205,16 +1205,63 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
throw new NotImplementedException(); return
M11.GetHashCode() +
M12.GetHashCode() +
M13.GetHashCode() +
M14.GetHashCode() +
M21.GetHashCode() +
M22.GetHashCode() +
M23.GetHashCode() +
M24.GetHashCode() +
M31.GetHashCode() +
M32.GetHashCode() +
M33.GetHashCode() +
M34.GetHashCode() +
M41.GetHashCode() +
M42.GetHashCode() +
M43.GetHashCode() +
M44.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return string.Format("{0} {1} {2} {3}\n{4} {5} {6} {7}\n{8} {9} {10} {11}\n{12} {13} {14} {15}", var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
M11, M12, M13, M14, var parts = new string[6];
M21, M22, M23, M24, parts[0] = "{ ";
M31, M32, M33, M34, parts[1] = string.Format(currentCulture, "{{M11:{0} M12:{1} M13:{2} M14:{3}}} ", new object[]
M41, M42, M43, M44); {
M11.ToString(currentCulture),
M12.ToString(currentCulture),
M13.ToString(currentCulture),
M14.ToString(currentCulture)
});
parts[2] = string.Format(currentCulture, "{{M21:{0} M22:{1} M23:{2} M24:{3}}} ", new object[]
{
M21.ToString(currentCulture),
M22.ToString(currentCulture),
M23.ToString(currentCulture),
M24.ToString(currentCulture)
});
parts[3] = string.Format(currentCulture, "{{M31:{0} M32:{1} M33:{2} M34:{3}}} ", new object[]
{
M31.ToString(currentCulture),
M32.ToString(currentCulture),
M33.ToString(currentCulture),
M34.ToString(currentCulture)
});
parts[4] = string.Format(currentCulture, "{{M41:{0} M42:{1} M43:{2} M44:{3}}} ", new object[]
{
M41.ToString(currentCulture),
M42.ToString(currentCulture),
M43.ToString(currentCulture),
M44.ToString(currentCulture)
});
parts[5] = "}";
return string.Concat(parts);
} }
#endregion #endregion

View File

@ -123,7 +123,7 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
return this.D.GetHashCode() ^ this.Normal.GetHashCode(); return this.D.GetHashCode() + this.Normal.GetHashCode();
} }
public PlaneIntersectionType Intersects(BoundingBox box) public PlaneIntersectionType Intersects(BoundingBox box)
@ -240,8 +240,12 @@ namespace ANX.Framework
public override string ToString() public override string ToString()
{ {
return "{{Normal:"+this.Normal.ToString()+" D:"+this.D.ToString()+"}}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{Normal:{0} D:{1}}}", new object[]
{
this.Normal.ToString(),
this.D.ToString(currentCulture)
});
} }
public static Plane Transform(Plane plane, Matrix matrix) public static Plane Transform(Plane plane, Matrix matrix)

View File

@ -83,12 +83,17 @@ namespace ANX.Framework
#region public methods #region public methods
public override int GetHashCode() public override int GetHashCode()
{ {
throw new Exception("method has not yet been implemented"); return this.X + this.Y;
} }
public override string ToString() public override string ToString()
{ {
throw new Exception("method has not yet been implemented"); var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{X:{0} Y:{1}}}", new object[]
{
this.X.ToString(currentCulture),
this.Y.ToString(currentCulture)
});
} }
#endregion #endregion

View File

@ -90,7 +90,7 @@ namespace ANX.Framework
/// </returns> /// </returns>
public override int GetHashCode() public override int GetHashCode()
{ {
return Position.GetHashCode() ^ Direction.GetHashCode(); return Position.GetHashCode() + Direction.GetHashCode();
} }
/* /*
@ -229,8 +229,12 @@ namespace ANX.Framework
/// </returns> /// </returns>
public override string ToString() public override string ToString()
{ {
return "{{Position:"+Position.ToString()+" Direction:"+Direction.ToString()+"}}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{Position:{0} Direction:{1}}}", new object[]
{
this.Position.ToString(),
this.Direction.ToString()
});
} }
#endregion #endregion

View File

@ -240,9 +240,17 @@ namespace ANX.Framework
this.Y += amount.Y; this.Y += amount.Y;
} }
public override string ToString() public override string ToString()
{ {
return "{X:" + this.X + " Y:" + this.Y + " Width:" + this.Width + " Height:" + this.Height + "}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{X:{0} Y:{1} Width:{2} Height:{3}}}", new object[]
{
this.X.ToString(currentCulture),
this.Y.ToString(currentCulture),
this.Width.ToString(currentCulture),
this.Height.ToString(currentCulture)
});
} }
#endregion #endregion

View File

@ -259,7 +259,7 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
return this.X.GetHashCode() ^ this.Y.GetHashCode(); return this.X.GetHashCode() + this.Y.GetHashCode();
} }
public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount) public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
@ -418,7 +418,12 @@ namespace ANX.Framework
public override string ToString() public override string ToString()
{ {
return "{X:" + this.X + " Y:" + this.Y + "}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{X:{0} Y:{1}}}", new object[]
{
this.X.ToString(currentCulture),
this.Y.ToString(currentCulture)
});
} }
public static Vector2 Transform(Vector2 position, Matrix matrix) public static Vector2 Transform(Vector2 position, Matrix matrix)

View File

@ -683,12 +683,18 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
return this.X.GetHashCode() ^ this.Y.GetHashCode() ^ this.Z.GetHashCode(); return this.X.GetHashCode() + this.Y.GetHashCode() + this.Z.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return "{X:" + this.X + " Y:" + this.Y + " Z:" + this.Z + "}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{X:{0} Y:{1} Z:{2}}}", new object[]
{
this.X.ToString(currentCulture),
this.Y.ToString(currentCulture),
this.Z.ToString(currentCulture)
});
} }
#endregion #endregion

View File

@ -546,12 +546,19 @@ namespace ANX.Framework
public override int GetHashCode() public override int GetHashCode()
{ {
return this.X.GetHashCode() ^ this.Y.GetHashCode() ^ this.Z.GetHashCode() ^ this.W.GetHashCode(); return this.X.GetHashCode() + this.Y.GetHashCode() + this.Z.GetHashCode() + this.W.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return "{X:" + this.X + " Y:" + this.Y + " Z:" + this.Z + " W:" + this.W + "}"; var currentCulture = System.Globalization.CultureInfo.CurrentCulture;
return string.Format(currentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", new object[]
{
this.X.ToString(currentCulture),
this.Y.ToString(currentCulture),
this.Z.ToString(currentCulture),
this.W.ToString(currentCulture)
});
} }
public float Length() public float Length()