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

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: expressive test macros (was: Report test_atomic_ops() failuresconsistently, via macros)
Дата
Msg-id f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: expressive test macros (was: Report test_atomic_ops() failuresconsistently, via macros)  (Noah Misch <noah@leadboat.com>)
Ответы Re: expressive test macros (was: Report test_atomic_ops() failuresconsistently, via macros)  (Noah Misch <noah@leadboat.com>)
Список pgsql-hackers
On 2019-10-06 04:20, Noah Misch wrote:
>> Seems like putting ASSERT_{EQ,LT,...}_{U32,S32,...} (or Assert_Eq_...,
>> but that'd imo look weirder than the inconsistency) into c.h would make
>> sense, and EXPECT_ somewhere in common/pg_test.h or such?
> 
> Sounds reasonable.  For broader use, I would include the expected value, not
> just expected_expr:
> 
>  elog(ERROR, \
>       "%s yielded %u, expected %s (%u) in file \"%s\" line %u", \
>       #result_expr, result, #expected_expr, expected, __FILE__, __LINE__); \
> 
> I didn't do that for the atomics tests, where expected_expr is always trivial.
> The codebase has plenty of Assert(x == y) where either of x or y could have
> the surprising value.

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.

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.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Missed check for too-many-children in bgworker spawning
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: expressive test macros (was: Report test_atomic_ops() failuresconsistently, via macros)