Menu

#10 assertEquals does not behave as expected

open
Framework (4)
5
2007-07-18
2007-03-22
Cuchaz
No

Consider the following coldfusion script example:

if( true neq 1 )
{
fail( "1 and true aren't equivalent" );
}
assertEquals( "boolean test failed", true, 1 );

The result output is "boolean test failed"

The expected behaviour is no failures reported.

Discussion

  • Cuchaz

    Cuchaz - 2007-03-22

    Logged In: YES
    user_id=1750338
    Originator: YES

    Here's another example regarding dates:

    assertEquals( "CreatedDate", "2005-08-30 16:12:12.130", objMyCFC.getCreatedDate() );
    assertEquals( "CreatedDate", "2005-08-30 16:12:12.13", objMyCFC.getCreatedDate() );

    objMyCFC.getCreatedDate() returns a coldfusion date primitive. When represented as a string, its value is "2005-08-30 16:12:12.13". The expected argument to assertEquals is a string representing a valid date and will be converted to an actual date primitive by the cf runtime when passed to a function whose argument specifies the "date" type.

    Both of these comparisons fail when they really shouldn't. It seems like the assert library needs more type awareness.

     
  • Robert Blackburn

    • assigned_to: nobody --> skorpiun
     

Log in to post a comment.