Compile time check preflight returns no tec (RIPD-1624):

The six different ranges of TER codes are broken up into six
different enumerations.  A template class allows subsets of
these enumerations to be aggregated.  This technique allows
verification at compile time that no TEC codes are returned
before the signature is checked.

Conversion between TER instance and integer is provided by
named functions.  This makes accidental conversion almost
impossible and makes type abuse easier to spot in the code
base.
This commit is contained in:
Scott Schurr
2018-04-16 17:51:36 -07:00
committed by seelabs
parent 7d163a45dc
commit 118c25c0f0
54 changed files with 612 additions and 161 deletions

View File

@@ -94,15 +94,16 @@ class Invariants_test : public beast::unit_test::suite
BEAST_EXPECT(precheck(A1, A2, ac));
auto tr = tesSUCCESS;
TER tr = tesSUCCESS;
// invoke check twice to cover tec and tef cases
for (auto i : {0,1})
{
tr = ac.checkInvariants(tr);
if (enabled)
{
BEAST_EXPECT(
tr == (i == 0 ? tecINVARIANT_FAILED : tefINVARIANT_FAILED));
BEAST_EXPECT(tr == (i == 0
? TER {tecINVARIANT_FAILED}
: TER {tefINVARIANT_FAILED}));
BEAST_EXPECT(
boost::starts_with(sink.strm_.str(), "Invariant failed:") ||
boost::starts_with(sink.strm_.str(),