Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx bad arithmetic. #11

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/quicr/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ class Name
constexpr Name operator^(const Name& other) const noexcept { return Name(_hi ^ other._hi, _lo ^ other._lo); }
constexpr Name operator~() const noexcept { return Name(~_hi, ~_lo); }

constexpr Name& operator&=(uint_t value) noexcept { return *this = *this | value; }
constexpr Name& operator&=(const Name& other) noexcept { return *this = *this | other; }
constexpr Name& operator&=(uint_t value) noexcept { return *this = *this & value; }
constexpr Name& operator&=(const Name& other) noexcept { return *this = *this & other; }
constexpr Name& operator|=(uint_t value) noexcept { return *this = *this | value; }
constexpr Name& operator|=(const Name& other) noexcept { return *this = *this | other; }
constexpr Name& operator^=(const Name& other) noexcept { return *this = *this ^ other; }
Expand Down
22 changes: 22 additions & 0 deletions test/name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,28 @@ TEST_CASE("quicr::Name Logical Arithmetic Tests")

auto short_arith_or = 0x0101010101010101_name | 0x1010101010101010;
CHECK_EQ(short_arith_or, 0x1111111111111111_name);

auto mask = 0xFFFFFFFFFFFFFFFF_name;
CHECK_EQ(~mask, 0xFFFFFFFFFFFFFFFF0000000000000000_name);
mask = ~mask;

{
auto some_name = 0xABCDEFABCDEF01234567890123456789_name;
some_name &= mask;
CHECK_EQ(some_name, 0xABCDEFABCDEF01230000000000000000_name);
}

{
auto some_name = 0xABCDEFABCDEF01234567890123456789_name;
some_name |= mask;
CHECK_EQ(some_name, 0xFFFFFFFFFFFFFFFF4567890123456789_name);
}

{
auto some_name = 0xABCDEFABCDEF01234567890123456789_name;
some_name ^= mask;
CHECK_EQ(some_name, 0x543210543210FEDC4567890123456789_name);
}
}

TEST_CASE("quicr::Name Conversion Tests")
Expand Down