On 04/30/2018 09:48 AM, David Malcolm wrote:
> Our selftest assertions were of the form:
>
> ASSERT_EQ (expected, actual)
>
> and both Richard Sandiford and I find this "Yoda ordering" confusing.
>
> Our existing tests aren't entirely consistent about this, and it doesn't make
> sense for ASSERT_NE and its variants.
>
> The ordering comes from googletest's API, which is what
> the earliest version of the selftest code used (before Bernd persuaded
> me to stop over-engineering it :) ).
>
> googletest's API now uses just "val1" and "val2" for binary assertion
> macros, and their docs now say:
>
> "Historical note: Before February 2016 *_EQ had a convention of calling
> it as ASSERT_EQ(expected, actual), so lots of existing code uses this
> order. Now *_EQ treats both parameters in the same way."
>
> This seems to have been:
> https://github.com/google/googletest/commit/f364e188372e489230ef4e44e1aec6bcb08f3acf
> https://github.com/google/googletest/pull/713
>
> This patch renames the params in our selftest API from "expected" and
> "actual" to "val1" and "val2".
>
> ASSERT_STREQ (and ASSERT_STREQ_AT) had an asymmetry in error-reporting, where
> they did a better job of reporting if the second of the params was NULL; this
> patch now handles params equivalently (and both must be non-NULL for a pass).
> We aren't able to selftest selftest failures, so I tested the five cases
> by hand while developing the patch (4 NULL vs non-NULL cases, with the both
> non-NULL case having a pass and fail sub-cases).
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk?
>
> gcc/ChangeLog:
> * selftest.c (assert_streq): Rename "expected" and "actual" to
> "val1" and "val2". Extend NULL-handling to cover both inputs
> symmetrically, while still requiring both to be non-NULL for a pass.
> * selftest.h (assert_streq): Rename "expected" and "actual" to
> "val1" and "val2".
> (ASSERT_EQ): Likewise.
> (ASSERT_EQ_AT): Likewise.
> (ASSERT_KNOWN_EQ): Likewise.
> (ASSERT_KNOWN_EQ_AT): Likewise.
> (ASSERT_NE): Likewise.
> (ASSERT_MAYBE_NE): Likewise.
> (ASSERT_MAYBE_NE_AT): Likewise.
> (ASSERT_STREQ): Likewise. Clarify that both must be non-NULL for
> the assertion to pass.
> (ASSERT_STREQ_AT): Likewise.
OK.
jeff