aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/UnicodeTest.cpp
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-07-25 16:52:48 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-31 20:11:19 +0000
commitf107a2fd014cd39c489060f2cd1b99cd49c7d0be (patch)
tree5c324821344901869203bbe055be8d3f69f696cb /tests/UnicodeTest.cpp
parent1935aa3d27cd4ed4aef2dc04360f247a541d4b00 (diff)
SkUTF
Create new header and namespace, `SkUTF` where we are putting all of our robust, well documented UTF-8, UTF-16, and UTF-32 functions: `SkUTF::{Count,Next,To}UTF{8,16,32}()`. SkUTF.h and SkUTF.cpp do not depend on the rest of Skia and are suitable for re-use in other modules. Some of the old UTF-{8,16} functions still live in SkUtils.h; their use will be phased out in future CLs. Also added more unit testing and cleaned up old tests. Removed functions that were unused outside of tests or used only once. Change-Id: Iaa59b8705abccf9c4ba082f855da368a0bad8380 Reviewed-on: https://skia-review.googlesource.com/143306 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tests/UnicodeTest.cpp')
-rw-r--r--tests/UnicodeTest.cpp36
1 files changed, 1 insertions, 35 deletions
diff --git a/tests/UnicodeTest.cpp b/tests/UnicodeTest.cpp
index 5ed92d4b34..5dbcf08547 100644
--- a/tests/UnicodeTest.cpp
+++ b/tests/UnicodeTest.cpp
@@ -9,39 +9,10 @@
#include "SkUtils.h"
#include "Test.h"
-// Unicode Variation Selector ranges: inclusive
-#define UVS_MIN0 0x180B
-#define UVS_MAX0 0x180D
-#define UVS_MIN1 0xFE00
-#define UVS_MAX1 0xFE0F
-#define UVS_MIN2 0xE0100
-#define UVS_MAX2 0xE01EF
-
-static bool isUVS(SkUnichar uni) {
- return (uni >= UVS_MIN0 && uni <= UVS_MAX0) ||
- (uni >= UVS_MIN1 && uni <= UVS_MAX1) ||
- (uni >= UVS_MIN2 && uni <= UVS_MAX2);
-}
-
-static void test_uvs(skiatest::Reporter* reporter) {
- // [min, max], [min, max] ... inclusive
- static const SkUnichar gRanges[] = {
- UVS_MIN0, UVS_MAX0, UVS_MIN1, UVS_MAX1, UVS_MIN2, UVS_MAX2
- };
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(gRanges); i += 2) {
- for (SkUnichar uni = gRanges[i] - 8; uni <= gRanges[i+1] + 8; ++uni) {
- bool uvs0 = isUVS(uni);
- bool uvs1 = SkUnichar_IsVariationSelector(uni);
- REPORTER_ASSERT(reporter, uvs0 == uvs1);
- }
- }
-}
-
// Simple test to ensure that when we call textToGlyphs, we get the same
// result (for the same text) when using UTF8, UTF16, UTF32.
// TODO: make the text more complex (i.e. incorporate chars>7bits)
-static void test_textencodings(skiatest::Reporter* reporter) {
+DEF_TEST(Unicode_textencodings, reporter) {
const char text8[] = "ABCDEFGabcdefg0123456789";
uint16_t text16[sizeof(text8)];
int32_t text32[sizeof(text8)];
@@ -76,8 +47,3 @@ static void test_textencodings(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !memcmp(glyphs8, glyphs16, count8 * sizeof(uint16_t)));
REPORTER_ASSERT(reporter, !memcmp(glyphs8, glyphs32, count8 * sizeof(uint16_t)));
}
-
-DEF_TEST(Unicode, reporter) {
- test_uvs(reporter);
- test_textencodings(reporter);
-}