From c9d816503da2dbdec840c95c2b0c148af0b5b51f Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 17 Mar 2019 17:57:17 -0500 Subject: [PATCH] [ox/std] Fix string number/char* append --- deps/ox/src/ox/std/string.hpp | 2 +- deps/ox/src/ox/std/test/CMakeLists.txt | 1 + deps/ox/src/ox/std/test/tests.cpp | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index 4f6c4397..0368f8fc 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -114,7 +114,7 @@ constexpr const BString &BString::operator+=(const char *str) noexce template constexpr const BString &BString::operator+=(char *str) noexcept { - return *this = static_cast(str); + return *this += static_cast(str); } template diff --git a/deps/ox/src/ox/std/test/CMakeLists.txt b/deps/ox/src/ox/std/test/CMakeLists.txt index ad9eccb7..6e9b0875 100644 --- a/deps/ox/src/ox/std/test/CMakeLists.txt +++ b/deps/ox/src/ox/std/test/CMakeLists.txt @@ -11,5 +11,6 @@ add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG") add_test("Test\\ ox_memcmp\\ ABCDEFG\\ ==\\ ABCDEFG" StdTest "ABCDEFG == ABCDEFG") add_test("Test\\ ox_memcmp\\ ABCDEFGHI\\ ==\\ ABCDEFG" StdTest "ABCDEFGHI == ABCDEFG") +add_test("Test\\ BString" StdTest "BString") add_test("Test\\ Vector" StdTest "Vector") add_test("Test\\ HashMap" StdTest "HashMap") diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index 0904067e..f5521ee7 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -37,6 +37,18 @@ map> tests = { return !(ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) == 0); } }, + { + "BString", + []() { + ox::BString<100> s; + s += "A"; + s += "B"; + s += 9; + s += "C"; + oxAssert(s == "AB9C", "BString append broken"); + return OxError(0); + } + }, { "Vector", [] {