From a5f998dd8f6af933cf786798d54a7dd0b0a2ee76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 1 Oct 2017 23:50:00 -0700 Subject: [PATCH] Fixed strCmpV. --- src/string.cpp | 2 +- tests/string_test.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/string.cpp b/src/string.cpp index d850b81..ebc5967 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -242,7 +242,7 @@ namespace bx if (0 == max) { - return 0; + return _lhsMax == _rhsMax ? 0 : _lhs[ii] - _rhs[ii]; } if ('0' != _lhs[idx] diff --git a/tests/string_test.cpp b/tests/string_test.cpp index 6c2d1b0..ed5b73b 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -8,6 +8,8 @@ #include #include +#include + bx::AllocatorI* g_allocator; TEST_CASE("chars", "") @@ -82,6 +84,7 @@ TEST_CASE("strCmpI", "") const char* empty = ""; REQUIRE(0 == bx::strCmpI(abvgd, abvgd) ); REQUIRE(0 == bx::strCmpI(abvgd, abvgx, 4) ); + REQUIRE(0 == bx::strCmpI(empty, empty) ); REQUIRE(0 > bx::strCmpI(abvgd, abvgx) ); REQUIRE(0 > bx::strCmpI(empty, abvgd) ); @@ -102,6 +105,7 @@ TEST_CASE("strCmpV", "") const char* empty = ""; REQUIRE(0 == bx::strCmpV(abvgd, abvgd) ); REQUIRE(0 == bx::strCmpV(abvgd, abvgx, 4) ); + REQUIRE(0 == bx::strCmpV(empty, empty) ); REQUIRE(0 > bx::strCmpV(abvgd, abvgx) ); REQUIRE(0 > bx::strCmpV(empty, abvgd) );