From 59d6e2a19e3e92229d3eb8a33d379894c480bb95 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Tue, 20 Apr 2021 14:25:06 +0200 Subject: [PATCH] dcsctp: Add test for StrongAlias as bool This test verifies that a StrongAlias can be evaluated as a boolean without dereferencing it. Note that this is not the case for StrongAlias, for example, as that wouldn't even compile. Which is quite good. Bug: webrtc:12614 Change-Id: I67329364721fe0354d78daac1233254035454c03 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215686 Reviewed-by: Florent Castelli Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/master@{#33787} --- net/dcsctp/public/strong_alias_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/dcsctp/public/strong_alias_test.cc b/net/dcsctp/public/strong_alias_test.cc index b0f97a73c2..0c57c6b248 100644 --- a/net/dcsctp/public/strong_alias_test.cc +++ b/net/dcsctp/public/strong_alias_test.cc @@ -347,4 +347,16 @@ TEST(StrongAliasTest, EnsureConstexpr) { static_assert(kOne > kZero, ""); static_assert(kOne >= kZero, ""); } + +TEST(StrongAliasTest, BooleansAreEvaluatedAsBooleans) { + using BoolAlias = StrongAlias; + + BoolAlias happy(true); + BoolAlias sad(false); + + EXPECT_TRUE(happy); + EXPECT_FALSE(sad); + EXPECT_TRUE(*happy); + EXPECT_FALSE(*sad); +} } // namespace dcsctp