Re: expressive test macros (was: Report test_atomic_ops() failures consistently, via macros)

From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: expressive test macros (was: Report test_atomic_ops() failures consistently, via macros)
Date: 2019-10-08 04:59:46
Message-ID: 20191008045946.GA4054860@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Oct 07, 2019 at 09:56:20PM +0200, Peter Eisentraut wrote:
> On 2019-10-06 04:20, Noah Misch wrote:
> > elog(ERROR, \
> > "%s yielded %u, expected %s (%u) in file \"%s\" line %u", \
> > #result_expr, result, #expected_expr, expected, __FILE__, __LINE__); \

> I've been meaning to propose some JUnit-style more-specific Assert
> variants such as AssertEquals for this reason. But as Tom writes
> nearby, it should be a straight wrapper around Assert, not elog. So
> these need to be named separately.

Agreed.

> Btw., JUnit uses the ordering convention assertEquals(expected, actual),
> whereas Perl Test::More uses is(actual, expected). Let's make sure we
> pick something and stick with it.

Since we write "if (actual == expected)", I prefer f(actual, expected). CUnit
uses CU_ASSERT_EQUAL(actual, expected).

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2019-10-08 05:05:10 pgsql: Clarify some comments about ntstatus.h in win32_port.h
Previous Message Michael Paquier 2019-10-08 02:50:44 pgsql: Improve test coverage of pg_rewind

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-10-08 05:05:16 Re: Non-Active links being referred in our source code
Previous Message Michael Paquier 2019-10-08 02:51:40 Re: Two pg_rewind patches (auto generate recovery conf and ensure clean shutdown)