Browse Source

Fixed toUpper/toLower string function.

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

+ 2 - 7
src/string.cpp

@@ -134,7 +134,7 @@ namespace bx
 	{
 		for (int32_t ii = 0; ii < _len; ++ii)
 		{
-			*_inOutStr = toLower(*_inOutStr);
+			_inOutStr[ii] = toLower(_inOutStr[ii]);
 		}
 	}
 
@@ -153,7 +153,7 @@ namespace bx
 	{
 		for (int32_t ii = 0; ii < _len; ++ii)
 		{
-			*_inOutStr = toUpper(*_inOutStr);
+			_inOutStr[ii] = toUpper(_inOutStr[ii]);
 		}
 	}
 
@@ -879,11 +879,6 @@ namespace bx
 				return 0;
 			}
 
-			if (_param.upper)
-			{
-				toUpperUnsafe(str, len);
-			}
-
 			const char* dot = strFind(str, INT32_MAX, '.');
 			if (NULL != dot)
 			{

+ 4 - 0
tests/vsnprintf_test.cpp

@@ -90,6 +90,7 @@ TEST_CASE("vsnprintf f")
 	REQUIRE(test("-1.2345670000e-9", "%.10f", -1.234567e-9) );
 
 	REQUIRE(test("3.141592",           "%f",    3.1415926535897932) );
+	REQUIRE(test("3.141592",           "%F",    3.1415926535897932) );
 	REQUIRE(test("3",                  "%.0f",  3.1415926535897932) );
 	REQUIRE(test("3.1",                "%.1f",  3.1415926535897932) );
 	REQUIRE(test("3.14",               "%.2f",  3.1415926535897932) );
@@ -107,8 +108,10 @@ TEST_CASE("vsnprintf f")
 	REQUIRE(test("3.14159265358979",   "%.14f", 3.1415926535897932) );
 	REQUIRE(test("3.141592653589793",  "%.15f", 3.1415926535897932) );
 	REQUIRE(test("3.1415926535897930", "%.16f", 3.1415926535897932) );
+	REQUIRE(test("3.1415926535897930", "%.16F", 3.1415926535897932) );
 
 	REQUIRE(test("-3.141592e-9",           "%f",    -3.1415926535897932e-9) );
+	REQUIRE(test("-3.141592E-9",           "%F",    -3.1415926535897932e-9) );
 	REQUIRE(test("-3e-9",                  "%.0f",  -3.1415926535897932e-9) );
 	REQUIRE(test("-3.1e-9",                "%.1f",  -3.1415926535897932e-9) );
 	REQUIRE(test("-3.14e-9",               "%.2f",  -3.1415926535897932e-9) );
@@ -126,6 +129,7 @@ TEST_CASE("vsnprintf f")
 	REQUIRE(test("-3.14159265358979e-9",   "%.14f", -3.1415926535897932e-9) );
 	REQUIRE(test("-3.141592653589793e-9",  "%.15f", -3.1415926535897932e-9) );
 	REQUIRE(test("-3.1415926535897930e-9", "%.16f", -3.1415926535897932e-9) );
+	REQUIRE(test("-3.1415926535897930E-9", "%.16F", -3.1415926535897932e-9) );
 
 	REQUIRE(test("1e-12", "%f", 1e-12));