SkStringPrintf helper fucntion + a new unit test for it.
git-svn-id: http://skia.googlecode.com/svn/trunk@1766 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
b371ed1784
commit
3a1f6a06cc
@ -197,4 +197,7 @@ private:
|
||||
uint16_t* fUCS2;
|
||||
};
|
||||
|
||||
/// Creates a new string and writes into it using a printf()-style format.
|
||||
SkString SkStringPrintf(const char* format, ...);
|
||||
|
||||
#endif
|
||||
|
@ -542,8 +542,6 @@ void SkString::prependf(const char format[], ...) {
|
||||
this->prepend(buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
#undef VSNPRINTF
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkString::remove(size_t offset, size_t length) {
|
||||
@ -605,3 +603,16 @@ SkAutoUCS2::SkAutoUCS2(const char utf8[]) {
|
||||
SkAutoUCS2::~SkAutoUCS2() {
|
||||
sk_free(fUCS2);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkString SkStringPrintf(const char* format, ...) {
|
||||
SkString formattedOutput;
|
||||
char buffer[kBufferSize];
|
||||
ARGS_TO_BUFFER(format, buffer, kBufferSize);
|
||||
formattedOutput.set(buffer);
|
||||
return formattedOutput;
|
||||
}
|
||||
|
||||
#undef VSNPRINTF
|
||||
|
||||
|
@ -85,6 +85,8 @@ static void TestString(skiatest::Reporter* reporter) {
|
||||
// SkDebugf(" received <%s> expected <%s>\n", a.c_str(), gRec[i].fString);
|
||||
REPORTER_ASSERT(reporter, a.equals(gRec[i].fString));
|
||||
}
|
||||
|
||||
REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0"));
|
||||
}
|
||||
|
||||
#include "TestClassDef.h"
|
||||
|
Loading…
Reference in New Issue
Block a user