The example code in README.md aims to test the += operator of safe_umx, but because it adds 42 to 0, it would also pass if the operator was (incorrectly) implemented as an assignment instead of an addition (as zero is the identity element of addition).
The fix would be to initialize data2 to a non-zero value.
|
constexpr auto data1{42_umx}; |
|
bsl::safe_umx data2{}; |
|
bsl::ut_when{} = [&]() noexcept { |
|
data2 += data1; |
|
bsl::ut_then{} = [&]() noexcept { |
|
bsl::ut_check(data2.checked() == data1); |
The example code in README.md aims to test the
+=operator ofsafe_umx, but because it adds 42 to 0, it would also pass if the operator was (incorrectly) implemented as an assignment instead of an addition (as zero is the identity element of addition).The fix would be to initialize
data2to a non-zero value.bsl/README.md
Lines 139 to 144 in 6509cff