skia2/tests/MiniDataTest.cpp
mtklein 6a5c7085bc Add SkMiniData.
This is a bit like a limited SkData, geared to store really tiny byte strings.

This is not hooked up anywhere beyond the new unit test.  I did experimentally
plumb it into SkRecord for drawPosTextH: just over 40% of drawPosTextH calls in
our repo can fit into ShortData.

BUG=skia:
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/573323002
2014-09-17 12:21:59 -07:00

17 lines
453 B
C++

#include "SkMiniData.h"
#include "Test.h"
DEF_TEST(MiniData, r) {
static const char* s = "abcdefghijklmnopqrstuvwxyz";
for (size_t len = 0; len <= 26; len++) {
SkMiniData md(s, len);
REPORTER_ASSERT(r, md.len() == len);
REPORTER_ASSERT(r, 0 == memcmp(md.data(), s, len));
SkMiniData copy(md);
REPORTER_ASSERT(r, copy.len() == len);
REPORTER_ASSERT(r, 0 == memcmp(copy.data(), s, len));
}
}