[Scummvm-git-logs] scummvm master -> 0a4154318ce95a5d45355f3980bdd47966c6a863
whoozle
vladimir.menshakov at gmail.com
Sat Sep 12 10:57:50 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0a4154318c COMMON: implement %c formatter (used in hardware-input.cpp)
Commit: 0a4154318ce95a5d45355f3980bdd47966c6a863
https://github.com/scummvm/scummvm/commit/0a4154318ce95a5d45355f3980bdd47966c6a863
Author: Vladimir Menshakov (vladimir.menshakov at gmail.com)
Date: 2020-09-12T11:56:17+01:00
Commit Message:
COMMON: implement %c formatter (used in hardware-input.cpp)
Fix invalid descriptor name for half-axis.
Add some tests for U32String::Format.
Changed paths:
common/ustr.cpp
test/common/str.h
diff --git a/common/ustr.cpp b/common/ustr.cpp
index 1da58dffe6..00584dd629 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -706,6 +706,12 @@ int U32String::vformat(U32String::const_iterator fmt, const U32String::const_ite
output.insertString(buffer, pos);
pos += len - 1;
break;
+ case 'c':
+ //char is promoted to int when passed through '...'
+ int_temp = va_arg(args, int);
+ output.insertChar(int_temp, pos);
+ ++length;
+ break;
default:
warning("Unexpected formatting type for U32String::Format.");
break;
diff --git a/test/common/str.h b/test/common/str.h
index 6d5a95aba7..6f72a45d96 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -364,6 +364,14 @@ class StringTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(s.size(), 7U);
}
+ void test_ustring_printf() {
+ //Ideally should be the same as above (make String template?)
+ TS_ASSERT_EQUALS( Common::U32String::format(" ").encode(), " " );
+ TS_ASSERT_EQUALS( Common::U32String::format("%s", "test").encode(), "test" );
+ TS_ASSERT_EQUALS( Common::U32String::format("%s%c%s", "Press ", 'X', " to win").encode(), "Press X to win" );
+ TS_ASSERT_EQUALS( Common::U32String::format("Some %s to make this string longer than the default built-in %s %d", "text", "capacity", 123456).encode(), "Some text to make this string longer than the default built-in capacity 123456" );
+ }
+
void test_strlcpy() {
static const char * const testString = "1234567890";
More information about the Scummvm-git-logs
mailing list