Skip to content

Example test in readme.md doesn't really test additionΒ #81

@Kristine1975

Description

@Kristine1975

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.

bsl/README.md

Lines 139 to 144 in 6509cff

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions