• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4  * COPYRIGHT:
5  * Copyright (c) 1997-2010, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  ********************************************************************/
8 
9 /**
10  * Normalizer basic tests
11  */
12 
13 #ifndef _TSTNORM
14 #define _TSTNORM
15 
16 #include "unicode/utypes.h"
17 
18 #if !UCONFIG_NO_NORMALIZATION
19 
20 #include "unicode/normlzr.h"
21 #include "intltest.h"
22 
23 class BasicNormalizerTest : public IntlTest {
24 public:
25     BasicNormalizerTest();
26     virtual ~BasicNormalizerTest();
27 
28     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = nullptr ) override;
29 
30     void TestHangulCompose();
31     void TestHangulDecomp();
32     void TestPrevious();
33     void TestDecomp();
34     void TestCompatDecomp();
35     void TestCanonCompose();
36     void TestCompatCompose();
37     void TestTibetan();
38     void TestCompositionExclusion();
39     void TestZeroIndex();
40     void TestVerisign();
41     void TestPreviousNext();
42     void TestNormalizerAPI();
43     void TestConcatenate();
44     void TestCompare();
45     void FindFoldFCDExceptions();
46     void TestSkippable();
47     void TestCustomComp();
48     void TestCustomFCC();
49     void TestFilteredNormalizer2Coverage();
50     void TestComposeUTF8WithEdits();
51     void TestDecomposeUTF8WithEdits();
52     void TestLowMappingToEmpty_D();
53     void TestLowMappingToEmpty_FCD();
54     void TestNormalizeIllFormedText();
55     void TestComposeJamoTBase();
56     void TestComposeBoundaryAfter();
57     void TestNFKC_SCF();
58 
59 private:
60     UnicodeString canonTests[24][3];
61     UnicodeString compatTests[11][3];
62     UnicodeString hangulCanon[2][3];
63 
64     void
65     TestPreviousNext(const char16_t *src, int32_t srcLength,
66                      const UChar32 *expext, int32_t expectLength,
67                      const int32_t *expectIndex, // its length=expectLength+1
68                      int32_t srcMiddle, int32_t expectMiddle,
69                      const char *moves,
70                      UNormalizationMode mode,
71                      const char *name);
72 
73     int32_t countFoldFCDExceptions(uint32_t foldingOptions);
74 
75     //------------------------------------------------------------------------
76     // Internal utilities
77     //
78     void backAndForth(Normalizer* iter, const UnicodeString& input);
79 
80     void staticTest(UNormalizationMode mode, int options,
81                     UnicodeString tests[][3], int length, int outCol);
82 
83     void iterateTest(Normalizer* iter, UnicodeString tests[][3], int length, int outCol);
84 
85     void assertEqual(const UnicodeString& input,
86              const UnicodeString& expected,
87              Normalizer* result,
88              const UnicodeString& errPrefix);
89 
90     static UnicodeString hex(char16_t ch);
91     static UnicodeString hex(const UnicodeString& str);
92 
93     void checkLowMappingToEmpty(const Normalizer2 &n2);
94 };
95 
96 #endif /* #if !UCONFIG_NO_NORMALIZATION */
97 
98 #endif // _TSTNORM
99