From: <dar...@us...> - 2009-06-10 15:57:04
|
Revision: 4446 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4446&view=rev Author: darioquintana Date: 2009-06-10 15:56:57 +0000 (Wed, 10 Jun 2009) Log Message: ----------- Removing ugly solution for floating point assert. Thanks to David Bachmann for the tip. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-06-10 14:46:46 UTC (rev 4445) +++ trunk/nhibernate/src/NHibernate.Test/HQL/HQLFunctions.cs 2009-06-10 15:56:57 UTC (rev 4446) @@ -567,6 +567,8 @@ [Test] public void Cast() { + const double magicResult = 7 + 123 - 5*1.3d; + IgnoreIfNotSupported("cast"); // The cast is used to test various cases of a function render // Cast was selected because represent a special case for: @@ -596,13 +598,7 @@ hql = "select cast(7+123-5*a.BodyWeight as Double) from Animal a"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - - if(Dialect is PostgreSQLDialect) - Assert.AreEqual(123.500000238419d, l[0]); - else - { - Assert.AreEqual(7 + 123 - 5 * 1.3d, l[0]); - } + Assert.AreEqual(magicResult, (double)l[0], 0.00001); // Rendered in SELECT using a property and nested functions if (!(Dialect is Oracle8iDialect)) @@ -653,13 +649,7 @@ hql = "select cast(7+123-5*a.BodyWeight as Double) from Animal a group by cast(7+123-5*a.BodyWeight as Double)"; l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - - if (Dialect is PostgreSQLDialect) - Assert.AreEqual(123.500000238419d, l[0]); - else - { - Assert.AreEqual(7 + 123 - 5 * 1.3d, l[0]); - } + Assert.AreEqual(magicResult, (double)l[0], 0.00001); // Rendered in GROUP BY using a property and nested functions if (!(Dialect is Oracle8iDialect)) @@ -743,11 +733,7 @@ string hql = "select cast(a.BodyWeight As Double) from Animal a"; IList l = s.CreateQuery(hql).List(); Assert.AreEqual(1, l.Count); - - if(Dialect is PostgreSQLDialect) - Assert.AreEqual(1.29999995231628d, l[0]); - else - Assert.AreEqual(1.3f, l[0]); + Assert.AreEqual(1.3f, (double)l[0], 0.00001); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |