Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: tests/StringTest.cpp

Issue 1403803002: SkStringPrintf and SkString::printf now are no longer limted by a static buffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-25 (Monday) 11:33:51 EDT Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFMetadata.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/StringTest.cpp
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp
index 9e41c48c845d689c740d1544c731a1652750f44c..8ae74121879ef2c57b73c9469b85d23ef721409c 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,26 @@ DEF_TEST(String, reporter) {
REPORTER_ASSERT(reporter, buffer[19] == 0);
REPORTER_ASSERT(reporter, buffer[20] == 'a');
+ REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0"));
+
+ // 2000 is larger than the static buffer size inside SkString.cpp
+ 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) {
« no previous file with comments | « src/pdf/SkPDFMetadata.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698