Fixed FloatsToTerseStrings and added a unit test proving it works
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@891 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -208,7 +208,7 @@ namespace libsecondlife
|
||||
/// <returns>A terse string representation of the input number</returns>
|
||||
public static string FloatToTerseString(float val)
|
||||
{
|
||||
string s = string.Format("{0:.00f}", val);
|
||||
string s = string.Format("{0:.00}", val);
|
||||
|
||||
// Trim trailing zeroes
|
||||
while (s[s.Length - 1] == '0')
|
||||
|
||||
@@ -62,10 +62,40 @@ namespace libsecondlife.Tests
|
||||
Assert.IsTrue(result == expected, a.ToString() + " * " + b.ToString() + " produced " + result.ToString() +
|
||||
" instead of " + expected.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VectorQuaternionMath()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FloatsToTerseStrings()
|
||||
{
|
||||
float f = 1.20f;
|
||||
string a = String.Empty;
|
||||
string b = "1.2";
|
||||
|
||||
a = Helpers.FloatToTerseString(f);
|
||||
Assert.IsTrue(a == b, f.ToString() + " converted to " + a + ", expecting " + b);
|
||||
|
||||
f = 24.00f;
|
||||
b = "24";
|
||||
|
||||
a = Helpers.FloatToTerseString(f);
|
||||
Assert.IsTrue(a == b, f.ToString() + " converted to " + a + ", expecting " + b);
|
||||
|
||||
f = -0.59f;
|
||||
b = "-.59";
|
||||
|
||||
a = Helpers.FloatToTerseString(f);
|
||||
Assert.IsTrue(a == b, f.ToString() + " converted to " + a + ", expecting " + b);
|
||||
|
||||
f = 0.59f;
|
||||
b = ".59";
|
||||
|
||||
a = Helpers.FloatToTerseString(f);
|
||||
Assert.IsTrue(a == b, f.ToString() + " converted to " + a + ", expecting " + b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user