Skip to content

Add _FMT for every assertions? #114

Open
@markand

Description

@markand

Hi,

For the moment, ASSERT_GTE does only print that the assertion fails with the given argument without expansion so in a debugging purpose it's not convenient as you always have to finally add some printf's or to start debugging:

* Suite basics:
F
FAIL example: x < y (main.c:18)

On the other hand ASSERT_EQ_FMT has the opportunity to print the different by expanding their values. Shouldn't we add _FMT for every assertion macros?

I think that may clutter the number of macros but unfortunately in C we don't have a good template mechanism to print values without specifying the format string (we could use _Generic but that's limited and requires C11).

We could also use some kind of literals macros:

  • ASSERT_INT_EQ|NE|LT|GT and so on, then printf could simply use %ju and force a cast (intmax_t) on the user values.
  • ASSERT_DOUBLE_... and so on, ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions