[ox/std] Fix BString == and != operators

This commit is contained in:
Gary Talent 2023-02-12 21:14:16 -06:00
parent 54eebf81da
commit 6d4c57d37d
2 changed files with 19 additions and 5 deletions

View File

@ -48,9 +48,13 @@ class BString {
constexpr BString operator+(Integer_c auto i) const noexcept; constexpr BString operator+(Integer_c auto i) const noexcept;
constexpr bool operator==(const BString &other) const noexcept; constexpr bool operator==(const char *other) const noexcept;
constexpr bool operator!=(const BString &other) noexcept; constexpr bool operator==(const OxString_c auto &other) const noexcept;
constexpr bool operator!=(const char *other) const noexcept;
constexpr bool operator!=(const OxString_c auto &other) noexcept;
constexpr char operator[](std::size_t i) const noexcept; constexpr char operator[](std::size_t i) const noexcept;
@ -167,12 +171,22 @@ constexpr BString<size> BString<size>::operator+(Integer_c auto i) const noexcep
} }
template<std::size_t buffLen> template<std::size_t buffLen>
constexpr bool BString<buffLen>::operator==(const BString<buffLen> &other) const noexcept { constexpr bool BString<buffLen>::operator==(const char *other) const noexcept {
return ox::StringView(*this) == other;
}
template<std::size_t buffLen>
constexpr bool BString<buffLen>::operator==(const OxString_c auto &other) const noexcept {
return ox::StringView(*this) == ox::StringView(other); return ox::StringView(*this) == ox::StringView(other);
} }
template<std::size_t buffLen> template<std::size_t buffLen>
constexpr bool BString<buffLen>::operator!=(const BString<buffLen> &other) noexcept { constexpr bool BString<buffLen>::operator!=(const char *other) const noexcept {
return !operator==(other);
}
template<std::size_t buffLen>
constexpr bool BString<buffLen>::operator!=(const OxString_c auto &other) noexcept {
return !operator==(other); return !operator==(other);
} }

View File

@ -206,7 +206,7 @@ static std::map<ox::String, ox::Error(*)()> tests = {
[] { [] {
constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db"; constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db";
oxRequire(uuid, ox::UUID::fromString(uuidStr)); oxRequire(uuid, ox::UUID::fromString(uuidStr));
oxExpect(ox::StringView(uuid.toString()), uuidStr); oxExpect(uuid.toString(), uuidStr);
return OxError(0); return OxError(0);
} }
}, },