Browse Source

Fixed issue #218.

Бранимир Караџић 6 years ago
parent
commit
d60912bcb5
2 changed files with 2 additions and 1 deletions
  1. 1 1
      src/string.cpp
  2. 1 0
      tests/string_test.cpp

+ 1 - 1
src/string.cpp

@@ -375,7 +375,7 @@ namespace bx
 
 
 	inline const char* strRFindUnsafe(const char* _str, int32_t _len, char _ch)
 	inline const char* strRFindUnsafe(const char* _str, int32_t _len, char _ch)
 	{
 	{
-		for (int32_t ii = _len; 0 <= ii; --ii)
+		for (int32_t ii = _len-1; 0 <= ii; --ii)
 		{
 		{
 			if (_str[ii] == _ch)
 			if (_str[ii] == _ch)
 			{
 			{

+ 1 - 0
tests/string_test.cpp

@@ -188,6 +188,7 @@ TEST_CASE("strRFind", "")
 	REQUIRE(bx::strRFind(bx::StringView(test, 0), 's').isEmpty() );
 	REQUIRE(bx::strRFind(bx::StringView(test, 0), 's').isEmpty() );
 	REQUIRE(bx::strRFind(bx::StringView(test, 1), 's').isEmpty() );
 	REQUIRE(bx::strRFind(bx::StringView(test, 1), 's').isEmpty() );
 	REQUIRE(&test[2] == bx::strRFind(test, 's').getPtr() );
 	REQUIRE(&test[2] == bx::strRFind(test, 's').getPtr() );
+	REQUIRE(&test[3] == bx::strRFind(test, 't').getPtr() );
 }
 }
 
 
 TEST_CASE("strFindI", "")
 TEST_CASE("strFindI", "")