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:
John Hurliman
2007-01-24 00:45:44 +00:00
parent 92f4a3ed8f
commit f477fde024
2 changed files with 31 additions and 1 deletions

View File

@@ -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')

View File

@@ -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);
}
}
}