• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <functional>
17 #include <gtest/gtest.h>
18 
19 #include "param_test_macros.h"
20 #include "char_groups.h"
21 #include "texgine_exception.h"
22 #include "text_converter.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 #define INVALID_CGS(...) \
28     {.object = invalid1Cgs_, ##__VA_ARGS__, .exception = ExceptionType::ERROR_STATUS}, \
29     {.object = invalid2Cgs_, ##__VA_ARGS__, .exception = ExceptionType::ERROR_STATUS}, \
30     {.object = invalid3Cgs_, ##__VA_ARGS__, .exception = ExceptionType::ERROR_STATUS}, \
31     {.object = invalid4Cgs_, ##__VA_ARGS__, .exception = ExceptionType::ERROR_STATUS}, \
32     {.object = invalid5Cgs_, ##__VA_ARGS__, .exception = ExceptionType::ERROR_STATUS}
33 
34 namespace OHOS {
35 namespace Rosen {
36 namespace TextEngine {
37 class CharGroupsTest : public testing::Test {
38 public:
SetUpTestCase()39     static void SetUpTestCase()
40     {
41         // {0x013B, 13.664} is {codepoint, advanceX}
42         normalCgs_.PushBack({.chars = TextConverter::ToUTF16("m"), .glyphs = {{0x013B, 13.664}}});
43         normalCgs_.PushBack({.chars = TextConverter::ToUTF16("o"), .glyphs = {{0x0145, 9.456}}});
44         normalCgs_.PushBack({.chars = TextConverter::ToUTF16("s"), .glyphs = {{0x0166, 7.28}}});
45         normalCgs_.PushBack({.chars = TextConverter::ToUTF16("t"), .glyphs = {{0x016E, 5.88}}});
46         glyphsCgs_.PushBack({.chars = TextConverter::ToUTF16("most"),
47             .glyphs = {{0x013B, 13.664}, {0x0145, 9.456}, {0x0166, 7.28}, {0x016E, 5.88}}});
48         normalSubCgs1_ = normalCgs_.GetSub(0, 1);
49         normalSubCgs2_ = normalCgs_.GetSub(1, 2);   // 1, 2 means getting the range of sub chargrops {start, end}
50     }
51 
52     static inline CharGroups normalCgs_ = CharGroups::CreateEmpty();
53     static inline CharGroups glyphsCgs_ = CharGroups::CreateEmpty();
54     static inline CharGroups emptyCgs_ = CharGroups::CreateEmpty();
55     static inline CharGroups defaultCgs_ = {};
56     static inline CharGroups normalSubCgs1_;
57     static inline CharGroups normalSubCgs2_;
58     // {6, 2} is chargrops range {start, end}
59     static inline CharGroups invalid1Cgs_ = CharGroups::CreateWithInvalidRange({6, 2});
60     static inline CharGroups invalid2Cgs_ = CharGroups::CreateWithInvalidRange({-1, 1});
61     static inline CharGroups invalid3Cgs_ = CharGroups::CreateWithInvalidRange({-4, -1});
62     static inline CharGroups invalid4Cgs_ = CharGroups::CreateWithInvalidRange({2, 5});
63     static inline CharGroups invalid5Cgs_ = CharGroups::CreateWithInvalidRange({0x7ffffffe, 0x7fffffff});
64     static inline CharGroup  cg_ = {.chars = TextConverter::ToUTF16("n"), .glyphs = {{0x013C, 13.664}}};
65 };
66 
GetObjectRangeChecker(int t1,int t2)67 auto GetObjectRangeChecker(int t1, int t2)
68 {
69     return [t1, t2](CharGroups &&ret) {
70         ASSERT_EQ(t1, ret.GetRange().start);
71         ASSERT_EQ(t2, ret.GetRange().end);
72     };
73 }
74 
GetIndexRangeChecker(int t1,int t2)75 auto GetIndexRangeChecker(int t1, int t2)
76 {
77     return [t1, t2](IndexRange ret) {
78         ASSERT_EQ(t1, ret.start);
79         ASSERT_EQ(t2, ret.end);
80     };
81 }
82 
83 /**
84  * @tc.name: GetNumberOfGlyph
85  * @tc.desc: Verify the GetNumberOfGlyph
86  * @tc.type:FUNC
87  * @tc.require: issueI6TIIF
88  */
89 DEFINE_PARAM_TEST0(CharGroups, GetNumberOfGlyph, {
90     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
91     // 0u, 4u: check the return value
92     {.object = emptyCgs_,    .checkFunc = GetResultChecker(0u)},
93     {.object = normalCgs_,   .checkFunc = GetResultChecker(4u)},
94     {.object = glyphsCgs_,   .checkFunc = GetResultChecker(4u)},
95 });
96 
97 /**
98  * @tc.name: GetNumberOfCharGroup
99  * @tc.desc: Verify the GetNumberOfCharGroup
100  * @tc.type:FUNC
101  * @tc.require: issueI6TIIF
102  */
103 DEFINE_PARAM_TEST0(CharGroups, GetNumberOfCharGroup, {
104     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
105     {.object = emptyCgs_,    .checkFunc = GetResultChecker(0u)},
106     {.object = normalCgs_,   .checkFunc = GetResultChecker(4u)},
107     {.object = glyphsCgs_,   .checkFunc = GetResultChecker(1u)},
108 });
109 
110 /**
111  * @tc.name: GetRange
112  * @tc.desc: Verify the GetRange
113  * @tc.type:FUNC
114  * @tc.require: issueI6TIIF
115  */
116 DEFINE_PARAM_TEST0(CharGroups, GetRange, {
117     // (6, 2) check the IndexRange
118     {.object = invalid1Cgs_, .checkFunc = GetIndexRangeChecker(6, 2)},
119     {.object = invalid2Cgs_, .checkFunc = GetIndexRangeChecker(-1, 1)},
120     {.object = invalid3Cgs_, .checkFunc = GetIndexRangeChecker(-4, -1)},
121     {.object = invalid4Cgs_, .checkFunc = GetIndexRangeChecker(2, 5)},
122     {.object = invalid5Cgs_, .checkFunc = GetIndexRangeChecker(0x7ffffffe, 0x7fffffff)},
123     {.object = defaultCgs_,  .checkFunc = GetIndexRangeChecker(0, 0)},
124     {.object = emptyCgs_,    .checkFunc = GetIndexRangeChecker(0, 0)},
125     {.object = normalCgs_,   .checkFunc = GetIndexRangeChecker(0, 4)},
126     {.object = glyphsCgs_,   .checkFunc = GetIndexRangeChecker(0, 1)},
127 });
128 
129 /**
130  * @tc.name: GetBack
131  * @tc.desc: Verify the GetBack
132  * @tc.type:FUNC
133  * @tc.require: issueI6TIIF
134  */
135 DEFINE_PARAM_TEST0(CharGroups, GetBack, {
136     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
137     {.object = emptyCgs_,    .exception = ExceptionType::OUT_OF_RANGE},
__anon584173a30302(CharGroup cg) 138     {.object = normalCgs_,   .checkFunc = [](CharGroup cg) {
139         ASSERT_EQ(TextConverter::ToStr(cg.chars), "t");
140     }},
__anon584173a30402(CharGroup cg) 141     {.object = glyphsCgs_,   .checkFunc = [](CharGroup cg) {
142         ASSERT_EQ(TextConverter::ToStr(cg.chars), "most");
143     }},
144 });
145 
146 /**
147  * @tc.name: GetSize
148  * @tc.desc: Verify the GetSize
149  * @tc.type:FUNC
150  * @tc.require: issueI6TIIF
151  */
152 DEFINE_PARAM_TEST0(CharGroups, GetSize, {
153     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
154     {.object = emptyCgs_,    .checkFunc = GetResultChecker(0u)},
155     {.object = normalCgs_,   .checkFunc = GetResultChecker(4u)},
156     {.object = glyphsCgs_,   .checkFunc = GetResultChecker(1u)},
157 });
158 
159 /**
160  * @tc.name: IsValid
161  * @tc.desc: Verify the IsValid
162  * @tc.type:FUNC
163  * @tc.require: issueI6TIIF
164  */
165 DEFINE_PARAM_TEST0(CharGroups, IsValid, {
166     {.object = defaultCgs_,  .checkFunc = GetResultChecker(false)},
167     {.object = emptyCgs_,    .checkFunc = GetResultChecker(true)},
168     {.object = normalCgs_,   .checkFunc = GetResultChecker(true)},
169     {.object = glyphsCgs_,   .checkFunc = GetResultChecker(true)},
170 });
171 
172 /**
173  * @tc.name: IsSameCharGroups
174  * @tc.desc: Verify the IsSameCharGroups
175  * @tc.type:FUNC
176  * @tc.require: issueI6TIIF
177  */
178 DEFINE_PARAM_TEST1(CharGroups, IsSameCharGroups, CharGroups, {
179     {.object = normalCgs_,     .arg1 = emptyCgs_,      .checkFunc = GetResultChecker(false)},
180     {.object = normalCgs_,     .arg1 = defaultCgs_,    .checkFunc = GetResultChecker(false)},
181     {.object = normalCgs_,     .arg1 = normalSubCgs1_, .checkFunc = GetResultChecker(true)},
182     {.object = normalCgs_,     .arg1 = normalSubCgs2_, .checkFunc = GetResultChecker(true)},
183     {.object = normalSubCgs1_, .arg1 = normalSubCgs2_, .checkFunc = GetResultChecker(true)},
184 });
185 
186 /**
187  * @tc.name: IsIntersect
188  * @tc.desc: Verify the IsIntersect
189  * @tc.type:FUNC
190  * @tc.require: issueI6TIIF
191  */
192 DEFINE_PARAM_TEST1(CharGroups, IsIntersect, CharGroups, {
193     {.object = emptyCgs_,      .arg1 = invalid3Cgs_,   .exception = ExceptionType::INVALID_ARGUMENT},
194     {.object = defaultCgs_,    .arg1 = defaultCgs_,    .exception = ExceptionType::INVALID_CHAR_GROUPS},
195     {.object = normalSubCgs1_, .arg1 = normalSubCgs2_, .checkFunc = GetResultChecker(false)},
196     {.object = normalCgs_,     .arg1 = normalSubCgs1_, .checkFunc = GetResultChecker(true)},
197     {.object = normalCgs_,     .arg1 = normalSubCgs2_, .checkFunc = GetResultChecker(true)},
198     {.object = normalCgs_,     .arg1 = glyphsCgs_,     .checkFunc = GetResultChecker(false)},
199 });
200 
201 /**
202  * @tc.name: GetSplit
203  * @tc.desc: Verify the GetSplit
204  * @tc.type:FUNC
205  * @tc.require: issueI6TIIF
206  */
207 DEFINE_PARAM_TEST1(CharGroups, GetSplit, int, {
208     // arg1 is parameters of GetSplit
209     {.object = normalCgs_,   .arg1 = -1, .exception = ExceptionType::INVALID_ARGUMENT},
210     {.object = defaultCgs_,  .arg1 = 1,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
211     {.object = normalCgs_,   .arg1 = 0,  .exception = ExceptionType::OUT_OF_RANGE},
212     {.object = normalCgs_,   .arg1 = 4,  .exception = ExceptionType::OUT_OF_RANGE},
__anon584173a30502(CharGroupsPair ret) 213     {.object = normalCgs_,   .arg1 = 1,  .checkFunc = [](CharGroupsPair ret) {
214         ASSERT_EQ(ret[0].GetRange().end, 1);
215         ASSERT_EQ(ret[1].GetRange().start, 1);
216     }},
__anon584173a30602(CharGroupsPair ret) 217     {.object = normalCgs_,   .arg1 = 3,  .checkFunc = [](CharGroupsPair ret) {
218         ASSERT_EQ(ret[0].GetRange().end, 3);
219         ASSERT_EQ(ret[1].GetRange().start, 3);
220     }},
221 });
222 
223 /**
224  * @tc.name: GetSplitAll
225  * @tc.desc: Verify the GetSplitAll
226  * @tc.type:FUNC
227  * @tc.require: issueI6TIIF
228  */
229 DEFINE_PARAM_TEST1(CharGroups, GetSplitAll, int, {
230     // arg1 is parameters of GetSplitAll
231     {.object = defaultCgs_,  .arg1 = 1, .exception = ExceptionType::INVALID_CHAR_GROUPS},
232     {.object = normalCgs_,   .arg1 = 0, .exception = ExceptionType::OUT_OF_RANGE},
233     {.object = normalCgs_,   .arg1 = 4, .exception = ExceptionType::OUT_OF_RANGE},
__anon584173a30702(CharGroupsPair ret) 234     {.object = normalCgs_,   .arg1 = 1, .checkFunc = [](CharGroupsPair ret) {
235         ASSERT_EQ(ret[0].GetRange().end, 1);
236         ASSERT_EQ(ret[1].GetRange().start, 1);
237     }},
__anon584173a30802(CharGroupsPair ret) 238     {.object = normalCgs_,   .arg1 = 3, .checkFunc = [](CharGroupsPair ret) {
239         ASSERT_EQ(ret[0].GetRange().end, 3);
240         ASSERT_EQ(ret[1].GetRange().start, 3);
241     }},
242 });
243 
244 /**
245  * @tc.name: GetSub
246  * @tc.desc: Verify the GetSub
247  * @tc.type:FUNC
248  * @tc.require: issueI6TIIF
249  */
250 DEFINE_PARAM_TEST2(CharGroups, GetSub, int, int, {
251     // arg1 and arg2 are parameters of GetSub, arg1 is start, arg2 is end
252     {.object = normalCgs_,     .arg1 = -1, .arg2 = 2, .exception = ExceptionType::INVALID_ARGUMENT},
253     {.object = normalCgs_,     .arg1 = 2,  .arg2 = 1, .exception = ExceptionType::INVALID_ARGUMENT},
254     {.object = normalSubCgs2_, .arg1 = -1, .arg2 = 1, .exception = ExceptionType::INVALID_ARGUMENT},
255     {.object = normalCgs_,     .arg1 = 2,  .arg2 = 6, .exception = ExceptionType::INVALID_ARGUMENT},
256     {.object = normalCgs_,     .arg1 = 0,  .arg2 = 0, .checkFunc = GetObjectRangeChecker(0, 0)},
257     {.object = normalCgs_,     .arg1 = 1,  .arg2 = 2, .checkFunc = GetObjectRangeChecker(1, 2)},
258     {.object = normalCgs_,     .arg1 = 4,  .arg2 = 4, .checkFunc = GetObjectRangeChecker(4, 4)},
259 });
260 
261 /**
262  * @tc.name: GetSubAll
263  * @tc.desc: Verify the GetSubAll
264  * @tc.type:FUNC
265  * @tc.require: issueI6TIIF
266  */
267 DEFINE_PARAM_TEST2(CharGroups, GetSubAll, int, int, {
268     // arg1 and arg2 are parameters of GetSubAll, arg1 is start, arg2 is end
269     {.object = defaultCgs_,  .arg1 = 0,  .arg2 = 0, .exception = ExceptionType::INVALID_CHAR_GROUPS},
270     {.object = normalCgs_,   .arg1 = -1, .arg2 = 2, .exception = ExceptionType::INVALID_ARGUMENT},
271     {.object = normalCgs_,   .arg1 = 2,  .arg2 = 1, .exception = ExceptionType::INVALID_ARGUMENT},
272     {.object = normalCgs_,   .arg1 = 1,  .arg2 = 9, .exception = ExceptionType::INVALID_ARGUMENT},
273     {.object = normalCgs_,   .arg1 = 0,  .arg2 = 0, .checkFunc = GetObjectRangeChecker(0, 0)},
274     {.object = normalCgs_,   .arg1 = 0,  .arg2 = 4, .checkFunc = GetObjectRangeChecker(0, 4)},
275     {.object = normalCgs_,   .arg1 = 2,  .arg2 = 3, .checkFunc = GetObjectRangeChecker(2, 3)},
276 });
277 
278 /**
279  * @tc.name: GetSubFromU16RangeAll
280  * @tc.desc: Verify the GetSubFromU16RangeAll
281  * @tc.type:FUNC
282  * @tc.require: issueI6TIIF
283  */
284 DEFINE_PARAM_TEST2(CharGroups, GetSubFromU16RangeAll, int, int, {
285     // arg1 and arg2 are parameters of GetSubFromU16RangeAll, arg1 is start, arg2 is end
286     {.object = defaultCgs_,  .arg1 = 1,  .arg2 = 2,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
287     {.object = normalCgs_,   .arg1 = -1, .arg2 = 2,  .exception = ExceptionType::INVALID_ARGUMENT},
288     {.object = normalCgs_,   .arg1 = 2,  .arg2 = 1,  .exception = ExceptionType::INVALID_ARGUMENT},
289     {.object = normalCgs_,   .arg1 = 10, .arg2 = 20, .exception = ExceptionType::INVALID_ARGUMENT},
290     {.object = normalCgs_,   .arg1 = 0,  .arg2 = 0,  .checkFunc = GetObjectRangeChecker(0, 0)},
291     {.object = normalCgs_,   .arg1 = 1,  .arg2 = 2,  .checkFunc = GetObjectRangeChecker(1, 2)},
292     {.object = normalCgs_,   .arg1 = 4,  .arg2 = 4,  .checkFunc = GetObjectRangeChecker(4, 4)},
293     {.object = glyphsCgs_,   .arg1 = 0,  .arg2 = 1,  .checkFunc = GetObjectRangeChecker(0, 1)},
294     {.object = glyphsCgs_,   .arg1 = 0,  .arg2 = 2,  .checkFunc = GetObjectRangeChecker(0, 1)},
295     {.object = glyphsCgs_,   .arg1 = 0,  .arg2 = 3,  .checkFunc = GetObjectRangeChecker(0, 1)},
296     {.object = glyphsCgs_,   .arg1 = 0,  .arg2 = 4,  .checkFunc = GetObjectRangeChecker(0, 1)},
297 });
298 
299 /**
300  * @tc.name: GetIntersect
301  * @tc.desc: Verify the GetIntersect
302  * @tc.type:FUNC
303  * @tc.require: issueI6TIIF
304  */
305 DEFINE_PARAM_TEST1(CharGroups, GetIntersect, CharGroups, {
306     {.object = normalCgs_,     .arg1 = invalid1Cgs_,   .exception = ExceptionType::INVALID_ARGUMENT},
307     {.object = defaultCgs_,    .arg1 = normalCgs_,     .exception = ExceptionType::INVALID_CHAR_GROUPS},
308     {.object = normalCgs_,     .arg1 = defaultCgs_,    .exception = ExceptionType::INVALID_ARGUMENT},
309     {.object = normalSubCgs1_, .arg1 = normalSubCgs2_, .exception = ExceptionType::CUSTOM},
310     {.object = normalCgs_,     .arg1 = normalSubCgs1_, .checkFunc = GetObjectRangeChecker(0, 1)},
311     {.object = normalCgs_,     .arg1 = normalSubCgs2_, .checkFunc = GetObjectRangeChecker(1, 2)},
312 });
313 
314 /**
315  * @tc.name: Get
316  * @tc.desc: Verify the Get
317  * @tc.type:FUNC
318  * @tc.require: issueI6TIIF
319  */
320 DEFINE_PARAM_TEST1(CharGroups, Get, int32_t, {
321     {.object = normalSubCgs2_, .arg1 = -1, .exception = ExceptionType::INVALID_ARGUMENT},
322     {.object = normalSubCgs1_, .arg1 = 0,
__anon584173a30902(struct CharGroup ret) 323      .checkFunc = [](struct CharGroup ret) {
324          ASSERT_EQ(TextConverter::ToStr(ret.chars), "m");
325     }},
326     {.object = normalSubCgs2_, .arg1 = 0,
__anon584173a30a02(struct CharGroup ret) 327      .checkFunc = [](struct CharGroup ret) {
328          ASSERT_EQ(TextConverter::ToStr(ret.chars), "o");
329     }},
330 });
331 
332 /**
333  * @tc.name: GetAll
334  * @tc.desc: Verify the GetAll
335  * @tc.type:FUNC
336  * @tc.require: issueI6TIIF
337  */
338 DEFINE_PARAM_TEST1(CharGroups, GetAll, int32_t, {
339     {.object = defaultCgs_,    .arg1 = 0,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
340     {.object = normalCgs_,     .arg1 = -1, .exception = ExceptionType::OUT_OF_RANGE},
341     {.object = normalCgs_,     .arg1 = 4,  .exception = ExceptionType::OUT_OF_RANGE},
342     {.object = normalCgs_,     .arg1 = 0,
__anon584173a30b02(struct CharGroup ret) 343      .checkFunc = [](struct CharGroup ret) {
344          ASSERT_EQ(TextConverter::ToStr(ret.chars), "m");
345     }},
346     {.object = normalSubCgs2_, .arg1 = 0,
__anon584173a30c02(struct CharGroup ret) 347      .checkFunc = [](struct CharGroup ret) {
348          ASSERT_EQ(TextConverter::ToStr(ret.chars), "m");
349     }},
350 });
351 
352 /**
353  * @tc.name: ToUTF16
354  * @tc.desc: Verify the ToUTF16
355  * @tc.type:FUNC
356  * @tc.require: issueI6TIIF
357  */
358 DEFINE_PARAM_TEST0(CharGroups, ToUTF16, {
359     {.object = defaultCgs_,    .exception = ExceptionType::INVALID_CHAR_GROUPS},
360     // 0 is the return size
361     {.object = emptyCgs_,      .checkFunc = GetVecSizeChecker<uint16_t>(0)},
362     {.object = normalCgs_,     .checkFunc = GetVecSizeChecker<uint16_t>(4)},
363     {.object = normalSubCgs1_, .checkFunc = GetVecSizeChecker<uint16_t>(1)},
364     {.object = normalSubCgs2_, .checkFunc = GetVecSizeChecker<uint16_t>(1)},
365     {.object = glyphsCgs_,     .checkFunc = GetVecSizeChecker<uint16_t>(4)},
366 });
367 
368 /**
369  * @tc.name: ToUTF16All
370  * @tc.desc: Verify the ToUTF16All
371  * @tc.type:FUNC
372  * @tc.require: issueI6TIIF
373  */
374 DEFINE_PARAM_TEST0(CharGroups, ToUTF16All, {
375     {.object = defaultCgs_,    .exception = ExceptionType::INVALID_CHAR_GROUPS},
376     {.object = emptyCgs_,      .checkFunc = GetVecSizeChecker<uint16_t>(0)},
377     {.object = normalCgs_,     .checkFunc = GetVecSizeChecker<uint16_t>(4)},
378     {.object = normalSubCgs1_, .checkFunc = GetVecSizeChecker<uint16_t>(4)},
379     {.object = normalSubCgs2_, .checkFunc = GetVecSizeChecker<uint16_t>(4)},
380     {.object = glyphsCgs_,     .checkFunc = GetVecSizeChecker<uint16_t>(4)},
381 });
382 
383 /**
384  * @tc.name: begin
385  * @tc.desc: Verify the begin
386  * @tc.type:FUNC
387  * @tc.require: issueI6XQ27
388  */
389 DEFINE_PARAM_TEST0(CharGroups, begin, {
390     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
__anon584173a30d02(std::vector<struct CharGroup>::iterator ret) 391     {.object = emptyCgs_,    .checkFunc = [&](std::vector<struct CharGroup>::iterator ret) {
392         ASSERT_EQ(ret, emptyCgs_.end());
393     }},
__anon584173a30e02(std::vector<struct CharGroup>::iterator ret) 394     {.object = normalCgs_,   .checkFunc = [](std::vector<struct CharGroup>::iterator ret) {
395         ASSERT_EQ(TextConverter::ToStr(ret->chars), "m");
396     }},
397 });
398 
399 /**
400  * @tc.name: end
401  * @tc.desc: Verify the end
402  * @tc.type:FUNC
403  * @tc.require: issueI6XQ27
404  */
405 DEFINE_PARAM_TEST0(CharGroups, end, {
406     {.object = defaultCgs_,  .exception = ExceptionType::INVALID_CHAR_GROUPS},
__anon584173a30f02(std::vector<struct CharGroup>::iterator ret) 407     {.object = emptyCgs_,    .checkFunc = [](std::vector<struct CharGroup>::iterator ret) {
408         ASSERT_EQ(ret, emptyCgs_.begin());
409     }},
__anon584173a31002(std::vector<struct CharGroup>::iterator ret) 410     {.object = normalCgs_,   .checkFunc = [](std::vector<struct CharGroup>::iterator ret) {
411         ASSERT_EQ(TextConverter::ToStr((ret - 1)->chars), "t");
412     }},
413 });
414 
GetCharGroupsEqualChecker(const CharGroups & cgs)415 auto GetCharGroupsEqualChecker(const CharGroups &cgs)
416 {
417     return [cgs](CharGroups &&obj) {
418         ASSERT_FALSE(obj.IsSameCharGroups(cgs));
419         ASSERT_EQ(obj.GetRange().start, cgs.GetRange().start);
420         ASSERT_EQ(obj.GetRange().end, cgs.GetRange().end);
421     };
422 }
423 
424 /**
425  * @tc.name: Clone
426  * @tc.desc: Verify the Clone
427  * @tc.type:FUNC
428  * @tc.require: issueI6XQ27
429  */
430 DEFINE_PARAM_TEST0(CharGroups, Clone, {
431     {.object = defaultCgs_,    .exception = ExceptionType::INVALID_CHAR_GROUPS},
432     {.object = emptyCgs_,      .checkFunc = GetCharGroupsEqualChecker(emptyCgs_)},
433     {.object = normalCgs_,     .checkFunc = GetCharGroupsEqualChecker(normalCgs_)},
434     {.object = normalSubCgs1_, .checkFunc = GetCharGroupsEqualChecker(normalSubCgs1_)},
435     {.object = normalSubCgs2_, .checkFunc = GetCharGroupsEqualChecker(normalSubCgs2_)},
436     {.object = glyphsCgs_,     .checkFunc = GetCharGroupsEqualChecker(glyphsCgs_)},
437 });
438 
439 /**
440  * @tc.name: Merge
441  * @tc.desc: Verify the Merge
442  * @tc.type:FUNC
443  * @tc.require: issueI6XQ27
444  */
445 DEFINE_VOID_PARAM_TEST1(CharGroups, Merge, CharGroups, {
446     {.object = defaultCgs_,    .arg1 = normalSubCgs1_, .exception = ExceptionType::INVALID_CHAR_GROUPS},
447     {.object = normalSubCgs1_, .arg1 = defaultCgs_,    .exception = ExceptionType::INVALID_ARGUMENT},
448     {.object = normalSubCgs1_, .arg1 = invalid1Cgs_,   .exception = ExceptionType::INVALID_ARGUMENT},
__anon584173a31202(CharGroups &arg1, CharGroups &obj) 449     {.object = normalSubCgs1_, .arg1 = normalSubCgs2_, .checkFunc = [](CharGroups &arg1, CharGroups &obj) {
450         ASSERT_EQ(obj.GetRange().end, 2);
451     }},
452 });
453 
454 /**
455  * @tc.name: PushBack
456  * @tc.desc: Verify the PushBack
457  * @tc.type:FUNC
458  * @tc.require: issueI6XQ27
459  */
460 DEFINE_VOID_PARAM_TEST1(CharGroups, PushBack, CharGroup, {
461     {.object = defaultCgs_,            .arg1 = cg_, .exception = ExceptionType::INVALID_CHAR_GROUPS},
__anon584173a31302(CharGroup &arg1, CharGroups &obj) 462     {.object = emptyCgs_.Clone(),      .arg1 = cg_, .checkFunc = [](CharGroup &arg1, CharGroups &obj) {
463         ASSERT_EQ(obj.GetSize(), 1);
464         ASSERT_EQ(TextConverter::ToStr(obj.GetAll(0).chars), "n");
465     }},
__anon584173a31402(CharGroup &arg1, CharGroups &obj) 466     {.object = normalCgs_.Clone(),     .arg1 = cg_, .checkFunc = [](CharGroup &arg1, CharGroups &obj) {
467         ASSERT_EQ(obj.GetSize(), 5);
468         ASSERT_EQ(TextConverter::ToStr(obj.GetAll(4).chars), "n");
469     }},
470     {.object = normalSubCgs1_.Clone(), .arg1 = cg_, .exception = ExceptionType::CUSTOM},
471     {.object = normalSubCgs2_.Clone(), .arg1 = cg_, .exception = ExceptionType::CUSTOM},
__anon584173a31502(CharGroup &arg1, CharGroups &obj) 472     {.object = glyphsCgs_.Clone(),     .arg1 = cg_, .checkFunc = [](CharGroup &arg1, CharGroups &obj) {
473         ASSERT_EQ(obj.GetSize(), 2);
474         ASSERT_EQ(TextConverter::ToStr(obj.GetAll(1).chars), "n");
475     }},
476 });
477 
478 /**
479  * @tc.name: ReverseAll
480  * @tc.desc: Verify the ReverseAll
481  * @tc.type:FUNC
482  * @tc.require: issueI6XQ27
483  */
484 DEFINE_VOID_PARAM_TEST0(CharGroups, ReverseAll, {
485     {.object = defaultCgs_,            .exception = ExceptionType::INVALID_CHAR_GROUPS},
__anon584173a31602(CharGroups &obj) 486     {.object = emptyCgs_.Clone(),      .checkFunc = [](CharGroups &obj) {}},
__anon584173a31702(CharGroups &obj) 487     {.object = normalCgs_.Clone(),     .checkFunc = [](CharGroups &obj) {
488         ASSERT_EQ(TextConverter::ToStr((obj.begin())->chars), "t");
489         ASSERT_EQ(TextConverter::ToStr((obj.end() - 1)->chars), "m");
490     }},
491     {.object = normalSubCgs1_.Clone(), .exception = ExceptionType::CUSTOM},
492     {.object = normalSubCgs2_.Clone(), .exception = ExceptionType::CUSTOM},
__anon584173a31802(CharGroups &obj) 493     {.object = glyphsCgs_.Clone(),     .checkFunc = [](CharGroups &obj) {
494         ASSERT_EQ(TextConverter::ToStr((obj.begin())->chars), "most");
495     }},
496 });
497 } // namespace TextEngine
498 } // namespace Rosen
499 } // namespace OHOS
500