Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: FEST-Assert 1.1
-
Fix Version/s: FEST-Assert 1.3
-
Component/s: Assert
-
Labels:None
-
Number of attachments :
Description
Hi there,
I've just upgraded to FEST 1.1 and I've noticed that the behaviour of DoubleAssert.isEqualTo() might have changed from previous version (I was upgrading from 1.01a). Previously assertThat((Double)null).isEqualTo(null), would pass, while now it throws a NullPointerException. Is this the intended behaviour? One way to deal with this would be to use assertThat(Object).isEqualTo(Object), but then we won't be able to provide a delta...
To sum up, ideally the signature could be DoubleAssert.isEqualTo(Double) and be null-aware as previously.
Thanks!
S.
PS. Using plain code names unaccompanied by the actual release version in JIRA might be confusing for people trying to determine the right Affects Version (the downloads section on the website uses numbers rather than code names) ![]()
Issue Links
| This issue is duplicated by: | ||||
| FEST-307 | assertThat(Integer) automatically unboxes Integers and returns IntAssert |
|
|
|
| This issue relates to: | ||||
| FEST-260 | Using Generic parameter in the super Assert classes such that many code can be moved up and remove in de sub classes. |
|
|
|
| This issue is depended upon by: | ||||
| FEST-197 | Add isNull, isNotNull to all Assert classes taking wrappers of primitive types as 'actual' value |
|
|
|
Most likely introduced by this change:
http://code.google.com/p/fest/source/diff?spec=svn1295&r=1295&format=side&path=/trunk/fest/fest-assert/src/main/java/org/fest/assertions/Assertions.java
Before, there were only assertThat() methods for primitive types, not for their wrappers.
Thus, writing assertThat((Double) null) would result in the compiler calling Assertions.assertThat(Object). This method returns ObjectAssert, which is capable of taking null as actual/expected value.
After this change, we have assertThat(Double actual), which returns a DoubleAssert. This assert class internally stores a primitive value, which gets initialized upon construction of the DoubleAssert object. Passing null to assertThat(...) will result in an assignment of null to a primitive double (java tries to performs auto-unboxing). This does not work for null, so we get the NPE observed by Stanislaw.
I'm going to try this: allow all subclasses of PrimitiveAssert to store references to the actual wrapper classes. This also helps a lot for
FEST-197.FEST-197.