Home | History | Annotate | Download | only in tests
      1 
      2 /*
      3  * Copyright 2011 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 #include "Test.h"
      9 #include "SkUtils.h"
     10 
     11 // Unicode Variation Selector ranges: inclusive
     12 #define UVS_MIN0    0x180B
     13 #define UVS_MAX0    0x180D
     14 #define UVS_MIN1    0xFE00
     15 #define UVS_MAX1    0xFE0F
     16 #define UVS_MIN2    0xE0100
     17 #define UVS_MAX2    0xE01EF
     18 
     19 static bool isUVS(SkUnichar uni) {
     20     return (uni >= UVS_MIN0 && uni <= UVS_MAX0) ||
     21            (uni >= UVS_MIN1 && uni <= UVS_MAX1) ||
     22            (uni >= UVS_MIN2 && uni <= UVS_MAX2);
     23 }
     24 
     25 static void test_uvs(skiatest::Reporter* reporter) {
     26     // [min, max], [min, max] ... inclusive
     27     static const SkUnichar gRanges[] = {
     28         UVS_MIN0, UVS_MAX0, UVS_MIN1, UVS_MAX1, UVS_MIN2, UVS_MAX2
     29     };
     30 
     31     for (size_t i = 0; i < SK_ARRAY_COUNT(gRanges); i += 2) {
     32         for (SkUnichar uni = gRanges[i] - 8; uni <= gRanges[i+1] + 8; ++uni) {
     33             bool uvs0 = isUVS(uni);
     34             bool uvs1 = SkUnichar_IsVariationSelector(uni);
     35             REPORTER_ASSERT(reporter, uvs0 == uvs1);
     36         }
     37     }
     38 }
     39 
     40 static void TestUnicode(skiatest::Reporter* reporter) {
     41     test_uvs(reporter);
     42 }
     43 
     44 #include "TestClassDef.h"
     45 DEFINE_TESTCLASS("Unicode", TestUnicodeClass, TestUnicode)
     46