1*0e209d39SAndroid Build Coastguard Worker /*
2*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2022 The Android Open Source Project
3*0e209d39SAndroid Build Coastguard Worker *
4*0e209d39SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*0e209d39SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*0e209d39SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*0e209d39SAndroid Build Coastguard Worker *
8*0e209d39SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*0e209d39SAndroid Build Coastguard Worker *
10*0e209d39SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*0e209d39SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*0e209d39SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*0e209d39SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*0e209d39SAndroid Build Coastguard Worker * limitations under the License.
15*0e209d39SAndroid Build Coastguard Worker */
16*0e209d39SAndroid Build Coastguard Worker
17*0e209d39SAndroid Build Coastguard Worker #include <gtest/gtest.h>
18*0e209d39SAndroid Build Coastguard Worker
19*0e209d39SAndroid Build Coastguard Worker #include <unicode/uchar.h>
20*0e209d39SAndroid Build Coastguard Worker #include <unicode/ustring.h>
21*0e209d39SAndroid Build Coastguard Worker #include <unicode/utrans.h>
22*0e209d39SAndroid Build Coastguard Worker
TEST(Icu4cUTransliteratorTest,test_utrans_transUChars)23*0e209d39SAndroid Build Coastguard Worker TEST(Icu4cUTransliteratorTest, test_utrans_transUChars) {
24*0e209d39SAndroid Build Coastguard Worker UErrorCode status = U_ZERO_ERROR;
25*0e209d39SAndroid Build Coastguard Worker UChar id[] = u"Any-Upper";
26*0e209d39SAndroid Build Coastguard Worker UTransliterator* utrans = utrans_openU(id, -1, UTRANS_FORWARD, NULL, 0, NULL, &status);
27*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U_ZERO_ERROR, status);
28*0e209d39SAndroid Build Coastguard Worker
29*0e209d39SAndroid Build Coastguard Worker UChar str[] = u"HeLlO WoRlD!";
30*0e209d39SAndroid Build Coastguard Worker int32_t len = sizeof(str) / sizeof(UChar) - 1;
31*0e209d39SAndroid Build Coastguard Worker
32*0e209d39SAndroid Build Coastguard Worker utrans_transUChars(utrans, str, NULL, len + 1 /*textCapacity*/, 0, &len, &status);
33*0e209d39SAndroid Build Coastguard Worker utrans_close(utrans);
34*0e209d39SAndroid Build Coastguard Worker UChar expected[] = u"HELLO WORLD!";
35*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(U_ZERO_ERROR, status);
36*0e209d39SAndroid Build Coastguard Worker ASSERT_EQ(0, u_strcmp(expected, str));
37*0e209d39SAndroid Build Coastguard Worker }
38*0e209d39SAndroid Build Coastguard Worker
39