aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/StringTest.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-04-22 08:03:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-22 08:03:03 -0700
commit606cadd5aac62299ef2e277709b3684cae2bf96c (patch)
tree40c5d32fc577c2eec86e6215134b17ea29e12cba /tests/StringTest.cpp
parentada338ab4edbe0ac644663aca6da205122fa5dac (diff)
SkStringPrintf and SkString::printf now are no longer limted by a static buffer
Diffstat (limited to 'tests/StringTest.cpp')
-rw-r--r--tests/StringTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp
index 9e41c48c84..0e71c2b988 100644
--- a/tests/StringTest.cpp
+++ b/tests/StringTest.cpp
@@ -148,6 +148,13 @@ DEF_TEST(String, reporter) {
a.appendU64(0x0000000001000000ULL, 15);
REPORTER_ASSERT(reporter, a.equals("000000016777216"));
+ a.printf("%i", 0);
+ REPORTER_ASSERT(reporter, a.equals("0"));
+ a.printf("%g", 3.14);
+ REPORTER_ASSERT(reporter, a.equals("3.14"));
+ a.printf("hello %s", "skia");
+ REPORTER_ASSERT(reporter, a.equals("hello skia"));
+
static const struct {
SkScalar fValue;
const char* fString;
@@ -185,6 +192,25 @@ DEF_TEST(String, reporter) {
REPORTER_ASSERT(reporter, buffer[19] == 0);
REPORTER_ASSERT(reporter, buffer[20] == 'a');
+ REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0"));
+
+ a = SkStringPrintf("%2000s", " ");
+ REPORTER_ASSERT(reporter, a.size() == 2000);
+ for (size_t i = 0; i < a.size(); ++i) {
+ if (a[i] != ' ') {
+ ERRORF(reporter, "SkStringPrintf fail: a[%d] = '%c'", i, a[i]);
+ break;
+ }
+ }
+ a.reset();
+ a.printf("%2000s", " ");
+ REPORTER_ASSERT(reporter, a.size() == 2000);
+ for (size_t i = 0; i < a.size(); ++i) {
+ if (a[i] != ' ') {
+ ERRORF(reporter, "SkStringPrintf fail: a[%d] = '%c'", i, a[i]);
+ break;
+ }
+ }
}
DEF_TEST(String_SkStrSplit, r) {