Menu

#10 Verbose message in CU_ASSERT_EQUAL()

open
nobody
None
5
2019-05-17
2006-07-12
Valentin
No

It would be of great help to provide more information
in the message when CU_ASSERT_EQUAL fails.
For example: "Expected: A, actual: B"
instead of the line number and the code. This way it
is possible to determine what went wrong without using
the debugger.

Discussion

  • Stephen Jackson

    Stephen Jackson - 2006-10-24

    Logged In: YES
    user_id=261025

    I would find this very useful. Here's the sort of thing I
    would want.

    1. ../dbg/mytest.c:1792  -
    

    CU_ASSERT_DOUBLE_EQUAL(total_charges,91 * 5.5,0.00000001)
    (495.00000000 == 500.50000000)

    (I achieved this by redefining CU_ASSERT_DOUBLE_EQUAL.)

    From my point of view, I'd like to see it as a #define
    option when I compile my tests (#ifdef CU_VERBOSE), and this
    is probably the simplest to implement. Alternative solutions
    could possibly involve CU_basic_set_mode() [I'm not sure
    this is possible]
    or a configuration flag when building the
    library.

    While I think that displaying numerics is fairly straight
    forward (but how much precision for doubles?), it is less
    clear how strings should be displayed. These will often
    contain linefeeds and an unexpected string could contain all
    kinds of gubbins.

     
  • Nobody/Anonymous

    I'd like to have the expected / actual information to all Assertions.
    is there any update on this request?

     
  • Anonymous

    Anonymous - 2013-05-06

    Same thing here, this would be very interesting for us as well.

     
  • Anonymous

    Anonymous - 2014-06-08

    Same. Is CUnit a live project?

     
    • Anonymous

      Anonymous - 2019-05-17
      Post awaiting moderation.
    • Ian Norton

      Ian Norton - 2019-05-17

      Yes CUnit is now hosted on gitlab.com at https://gitlab.com/cunity/cunit

       
  • Ian Norton

    Ian Norton - 2019-05-17

    I have logged this over in gitlab https://gitlab.com/cunity/cunit/issues/26

     

Anonymous
Anonymous

Add attachments
Cancel