aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GlyphRunTest.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-07-09 17:06:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-10 22:15:05 +0000
commit819f73c23cfd8471e1cbc77ee7c14d8150457765 (patch)
tree9c0a8097d37d7c022439de6fee4642a11fa062a3 /tests/GlyphRunTest.cpp
parent02ca49fc466bc54831c3a8f03b1b3c6ab6bba498 (diff)
Use new SkGlyphIDSet
Change-Id: I6b8080393a22a56577528f66630ad39372edf712 Reviewed-on: https://skia-review.googlesource.com/140243 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tests/GlyphRunTest.cpp')
-rw-r--r--tests/GlyphRunTest.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/GlyphRunTest.cpp b/tests/GlyphRunTest.cpp
index 46b4715c61..0e0c441b75 100644
--- a/tests/GlyphRunTest.cpp
+++ b/tests/GlyphRunTest.cpp
@@ -11,25 +11,32 @@
#include "Test.h"
-DEF_TEST(GlyphSetBasic, reporter) {
- SkGlyphSet set;
-
- std::vector<SkGlyphID> unique;
-
- set.reuse(10, &unique);
- REPORTER_ASSERT(reporter, set.add(7) == 0);
- REPORTER_ASSERT(reporter, set.add(3) == 1);
- set.reuse(10, &unique);
- REPORTER_ASSERT(reporter, set.add(5) == 0);
- REPORTER_ASSERT(reporter, set.add(8) == 1);
- REPORTER_ASSERT(reporter, set.add(3) == 2);
-
- REPORTER_ASSERT(reporter, unique.size() == 5);
- REPORTER_ASSERT(reporter, unique[0] == 7);
- REPORTER_ASSERT(reporter, unique[1] == 3);
- REPORTER_ASSERT(reporter, unique[2] == 5);
- REPORTER_ASSERT(reporter, unique[3] == 8);
- REPORTER_ASSERT(reporter, unique[4] == 3);
+DEF_TEST(GlyphRunGlyphIDSetBasic, reporter) {
+ SkGlyphID glyphs[] = {100, 3, 240, 3, 234};
+ auto glyphIDs = SkSpan<const SkGlyphID>(glyphs, SK_ARRAY_COUNT(glyphs));
+ int universeSize = 1000;
+ SkGlyphID uniqueGlyphs[SK_ARRAY_COUNT(glyphs)];
+ uint16_t denseIndices[SK_ARRAY_COUNT(glyphs)];
+
+ SkGlyphIDSet gs;
+ auto uniqueGlyphIDs = gs.uniquifyGlyphIDs(universeSize, glyphIDs, uniqueGlyphs, denseIndices);
+
+ std::vector<SkGlyphID> test{uniqueGlyphIDs.begin(), uniqueGlyphIDs.end()};
+ std::sort(test.begin(), test.end());
+ auto newEnd = std::unique(test.begin(), test.end());
+ REPORTER_ASSERT(reporter, uniqueGlyphIDs.size() == newEnd - test.begin());
+ REPORTER_ASSERT(reporter, uniqueGlyphIDs.size() == 4);
+ {
+ uint16_t answer[] = {0, 1, 2, 1, 3};
+ REPORTER_ASSERT(reporter,
+ std::equal(answer, std::end(answer), denseIndices));
+ }
+
+ {
+ SkGlyphID answer[] = {100, 3, 240, 234};
+ REPORTER_ASSERT(reporter,
+ std::equal(answer, std::end(answer), uniqueGlyphs));
+ }
}
DEF_TEST(GlyphRunBasic, reporter) {