diff options
| author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-02-27 22:06:06 +0000 |
|---|---|---|
| committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-02-27 22:06:06 +0000 |
| commit | d8730ea8b25d692c0656f8cf03f02aecfab2a17c (patch) | |
| tree | 7a1c8cac5a1433a8ced46bf6dc0f71675e168d76 /tests/StringTest.cpp | |
| parent | ed673310e2551e64d8196f7776d7d4c92085f8c2 (diff) | |
more tests (need more meat in there)
git-svn-id: http://skia.googlecode.com/svn/trunk@97 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/StringTest.cpp')
| -rw-r--r-- | tests/StringTest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp new file mode 100644 index 0000000000..344c752c8c --- /dev/null +++ b/tests/StringTest.cpp @@ -0,0 +1,54 @@ +#include "Test.h" +#include "SkString.h" + +static void TestString(skiatest::Reporter* reporter) { + SkString a; + SkString b((size_t)0); + SkString c(""); + SkString d(NULL, 0); + + REPORTER_ASSERT(reporter, a.isEmpty()); + REPORTER_ASSERT(reporter, a == b && a == c && a == d); + + a.set("hello"); + b.set("hellox", 5); + c.set(a); + d.resize(5); + memcpy(d.writable_str(), "helloz", 5); + + REPORTER_ASSERT(reporter, !a.isEmpty()); + REPORTER_ASSERT(reporter, a.size() == 5); + REPORTER_ASSERT(reporter, a == b && a == c && a == d); + REPORTER_ASSERT(reporter, a.equals("hello", 5)); + REPORTER_ASSERT(reporter, a.equals("hello")); + REPORTER_ASSERT(reporter, !a.equals("help")); + + SkString e(a); + SkString f("hello"); + SkString g("helloz", 5); + + REPORTER_ASSERT(reporter, a == e && a == f && a == g); + + b.set("world"); + c = b; + REPORTER_ASSERT(reporter, a != b && a != c && b == c); + + a.append(" world"); + e.append("worldz", 5); + e.insert(5, " "); + f.set("world"); + f.prepend("hello "); + REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f); + + a.reset(); + b.resize(0); + REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b); + + a.set("a"); + a.set("ab"); + a.set("abc"); + a.set("abcd"); +} + +#include "TestClassDef.h" +DEFINE_TESTCLASS("String", StringTestClass, TestString) |
