未验证 提交 5cbd7cdc 编写于 作者: O openharmony_ci 提交者: Gitee

!8628 modify cases in i18n

Merge pull request !8628 from 杨清/master
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function BreakIteratorInI18nTest() {
describe('BreakIteratorInI18nTest', function () {
console.log('*************start BreakIteratorInI18nTest*************');
let hour = I18n.System.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in I18n.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case in I18n.');
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0100
* @tc.name test current interface
* @tc.desc check the current result
*/
it('i18n_test_iterator_0100', 0, function () {
console.log('i18n_test_iterator_0100 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.current();
console.log('i18n_test_iterator_0100 ' + value);
expect(value).assertEqual(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0200
* @tc.name test first interface
* @tc.desc check the first
*/
it('i18n_test_iterator_0200', 0, function () {
console.log('i18n_test_iterator_0200 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.first();
console.log('i18n_test_iterator_0200 ' + value);
expect(value).assertEqual(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0300
* @tc.name test last interface
* @tc.desc check the last interface
*/
it('i18n_test_iterator_0300', 0, function () {
console.log('i18n_test_iterator_0300 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.last();
console.log('i18n_test_iterator_0300 ' + value);
expect(value).assertEqual(40);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0400
* @tc.name test next interface
* @tc.desc check the next interface
*/
it('i18n_test_iterator_0400', 0, function () {
console.log('i18n_test_iterator_0400 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.next();
console.log('i18n_test_iterator_0400 ' + value);
expect(value).assertEqual(3);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0500
* @tc.name test next interface with param
* @tc.desc check the next interface with param
*/
it('i18n_test_iterator_0500', 0, function () {
console.log('i18n_test_iterator_0500 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.next(2);
console.log('i18n_test_iterator_0500 ' + value);
expect(value).assertEqual(8);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0600
* @tc.name test previous interface
* @tc.desc check the previous interface
*/
it('i18n_test_iterator_0600', 0, function () {
console.log('i18n_test_iterator_0600 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.previous();
console.log('i18n_test_iterator_0600 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0700
* @tc.name test following interface
* @tc.desc check the following interface
*/
it('i18n_test_iterator_0700', 0, function () {
console.log('i18n_test_iterator_0700 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.following(1);
console.log('i18n_test_iterator_0700 ' + value);
expect(value).assertEqual(3);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0800
* @tc.name test getLineBreakText interface
* @tc.desc check the getLineBreakText interface
*/
it('i18n_test_iterator_0800', 0, function () {
console.log('i18n_test_iterator_0800 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.getLineBreakText();
console.log('i18n_test_iterator_0800 ' + value);
expect(value).assertEqual('My name is Tom.Welcome to the sky world.');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0900
* @tc.name test isBoundary interface
* @tc.desc check the isBoundary interface
*/
it('i18n_test_iterator_0900', 0, function () {
console.log('i18n_test_iterator_0900 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.isBoundary(10);
console.log('i18n_test_iterator_0900 ' + value);
expect(value).assertFalse();
// current
let current = iterator.current();
console.log('i18n_test_iterator_0900 ' + current);
expect(current).assertEqual(11);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_1000
* @tc.name test iterator interface
* @tc.desc check the iterator interface
*/
it('i18n_test_iterator_1000', 0, function () {
console.log('i18n_test_iterator_1000 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
// current
let current = iterator.current();
console.log('i18n_test_iterator_1000 ' + current);
expect(current).assertEqual(0);
// next
let next = iterator.next();
console.log('i18n_test_iterator_1000 ' + next);
expect(next).assertEqual(3);
// current
let current2 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current2);
expect(current2).assertEqual(3);
// next 5
let next2 = iterator.next(5);
console.log('i18n_test_iterator_1000 ' + next2);
expect(next2).assertEqual(30);
// previous
let previous = iterator.previous();
console.log('i18n_test_iterator_1000 ' + previous);
expect(previous).assertEqual(26);
// following 2
let follwoing = iterator.following(3);
console.log('i18n_test_iterator_1000 ' + follwoing);
expect(follwoing).assertEqual(8);
// current
let current3 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current3);
expect(current3).assertEqual(8);
// isBoundary
let value = iterator.isBoundary(3);
console.log('i18n_test_iterator_1000 ' + value);
expect(value).assertTrue();
// current
let current4 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current4);
expect(current4).assertEqual(3);
})
console.log('*************end BreakIteratorInI18nTest*************');
})}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function CalendarInI18nTest() {
describe('CalendarInI18nTest', function () {
console.log('*************start CalendarInI18nTest*************');
let hour = I18n.System.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in I18n.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case in I18n.');
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0100
* @tc.name test isWeekend interface
* @tc.desc get the isWeekend value
*/
it('i18n_calendar_test_0100', 0, function () {
console.log('i18n_calendar_test_0100 ' + 'start');
let calendar = I18n.getCalendar('zh');
let value = calendar.isWeekend(new Date(2021, 10, 1, 10, 0, 0, 0));
console.log('i18n_calendar_test_0100 ' + value);
expect(value).assertFalse();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0200
* @tc.name test getCalendar interface
* @tc.desc get the getCalendar value
*/
it('i18n_calendar_test_0200', 0, function () {
console.log('i18n_calendar_test_0200 ' + 'start');
let calendar = I18n.getCalendar('ja', 'japanese');
let name = calendar.getDisplayName('ja');
console.log('i18n_calendar_test_0200 ' + name);
expect(name).assertEqual('和暦');
let timezone = calendar.getTimeZone();
console.log('i18n_calendar_test_0200 ' + timezone);
expect(timezone.length > 0).assertTrue();
let firstday = calendar.getFirstDayOfWeek();
console.log('i18n_calendar_test_0200 ' + firstday);
expect(firstday).assertEqual(1);
let miniday = calendar.getMinimalDaysInFirstWeek();
console.log('i18n_calendar_test_0200 ' + miniday);
expect(miniday).assertEqual(1);
let value = calendar.isWeekend(new Date(2022, 10, 1, 10, 0, 0, 0));
console.log('i18n_calendar_test_0200 ' + value);
expect(value).assertFalse();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0300
* @tc.name test getCalendar interface with zh param
* @tc.desc get the getCalendar value
*/
it('i18n_calendar_test_0300', 0, function () {
console.log('i18n_calendar_test_0300 ' + 'start');
let calendar = I18n.getCalendar('zh', 'chinese');
let name = calendar.getDisplayName('zh');
console.log('i18n_calendar_test_0300 ' + name);
expect(name).assertEqual('农历');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0400
* @tc.name test getCalendar interface with zh param
* @tc.desc get the getCalendar value
*/
it('i18n_calendar_test_0400', 0, function () {
console.log('i18n_calendar_test_0400 ' + 'start');
let calendar = I18n.getCalendar('zh', 'japanese');
let name = calendar.getDisplayName('zh');
console.log('i18n_calendar_test_0400 ' + name);
expect(name).assertEqual('和历');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0500
* @tc.name test getDisplayName interface
* @tc.desc get the getDisplayName value
*/
it('i18n_calendar_test_0500', 0, function () {
console.log('i18n_calendar_test_0500 ' + 'start');
let calendar = I18n.getCalendar('zh');
let value = calendar.getDisplayName('zh');
console.log('i18n_calendar_test_0500 ' + value);
expect(value).assertEqual('公历');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0600
* @tc.name test getDisplayName interface with en param
* @tc.desc get the getDisplayName value
*/
it('i18n_calendar_test_0600', 0, function () {
console.log('i18n_calendar_test_0600 ' + 'start');
let calendar = I18n.getCalendar('zh');
let value = calendar.getDisplayName('en');
console.log('i18n_calendar_test_0600 ' + value);
expect(value).assertEqual('Gregorian Calendar');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0700
* @tc.name test get interface
* @tc.desc get the get value
*/
it('i18n_calendar_test_0700', 0, function () {
console.log('i18n_calendar_test_0700 ' + 'start');
let calendar = I18n.getCalendar('zh');
let value = calendar.get('year');
console.log('i18n_calendar_test_0700 ' + value);
expect(value).assertLarger(0);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0800
* @tc.name test get interface with month param
* @tc.desc get the get value
*/
it('i18n_calendar_test_0800', 0, function () {
console.log('i18n_calendar_test_0800 ' + 'start');
let calendar = I18n.getCalendar('zh');
let date1 = new Date(2021, 8, 8, 8, 8, 8, 8);
calendar.setTime(date1);
let value = calendar.get('month');
console.log('i18n_calendar_test_0800 ' + value);
expect(value).assertEqual(8);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_0900
* @tc.name test get interface with day_of_year param
* @tc.desc get the get value
*/
it('i18n_calendar_test_0900', 0, function () {
console.log('i18n_calendar_test_0900 ' + 'start');
let calendar = I18n.getCalendar('zh');
let value = calendar.get('day_of_year');
console.log('i18n_calendar_test_0900 ' + value);
expect(value).assertLarger(0);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1000
* @tc.name test setMinimalDaysInFirstWeek and getMinimalDaysInFirstWeek interface
* @tc.desc get the setMinimalDaysInFirstWeek and getMinimalDaysInFirstWeek value
*/
it('i18n_calendar_test_1000', 0, function () {
console.log('i18n_calendar_test_1000 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setMinimalDaysInFirstWeek(1);
let value = calendar.getMinimalDaysInFirstWeek();
console.log('i18n_calendar_test_1000 ' + value);
expect(value).assertEqual(1);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1100
* @tc.name test setMinimalDaysInFirstWeek with 0 param and getMinimalDaysInFirstWeek interface
* @tc.desc get the setMinimalDaysInFirstWeek and getMinimalDaysInFirstWeek value
*/
it('i18n_calendar_test_1100', 0, function () {
console.log('i18n_calendar_test_1100 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setMinimalDaysInFirstWeek(0);
let value = calendar.getMinimalDaysInFirstWeek();
console.log('i18n_calendar_test_1100 ' + value);
expect(value).assertEqual(1);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1200
* @tc.name test setMinimalDaysInFirstWeek with 8 param and getMinimalDaysInFirstWeek interface
* @tc.desc get the setMinimalDaysInFirstWeek and getMinimalDaysInFirstWeek value
*/
it('i18n_calendar_test_1200', 0, function () {
console.log('i18n_calendar_test_1200 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setMinimalDaysInFirstWeek(8);
let value = calendar.getMinimalDaysInFirstWeek();
console.log('i18n_calendar_test_1200 ' + value);
expect(value).assertEqual(7);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1300
* @tc.name test setMinimalDaysInFirstWeek with 7 param and getMinimalDaysInFirstWeek interface
* @tc.desc get the setMinimalDaysInFirstWeek and getMinimalDaysInFirstWeek value
*/
it('i18n_calendar_test_1300', 0, function () {
console.log('i18n_calendar_test_1300 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setMinimalDaysInFirstWeek(7);
let value = calendar.getMinimalDaysInFirstWeek();
console.log('i18n_calendar_test_1300 ' + value);
expect(value).assertEqual(7);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1400
* @tc.name test setFirstDayOfWeek and getFirstDayOfWeek interface
* @tc.desc get the setFirstDayOfWeek and getFirstDayOfWeek value
*/
it('i18n_calendar_test_1400', 0, function () {
console.log('i18n_calendar_test_1400 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setFirstDayOfWeek(1);
let value = calendar.getFirstDayOfWeek();
console.log('i18n_calendar_test_1400 ' + value);
expect(value).assertEqual(1);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1500
* @tc.name test setFirstDayOfWeek with 0 param and getFirstDayOfWeek interface
* @tc.desc get the setFirstDayOfWeek and getFirstDayOfWeek value
*/
it('i18n_calendar_test_1500', 0, function () {
console.log('i18n_calendar_test_1500 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setFirstDayOfWeek(0);
let value = calendar.getFirstDayOfWeek();
console.log('i18n_calendar_test_1500 ' + value);
expect(value).assertEqual(1);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1600
* @tc.name test setFirstDayOfWeek with 7 param and getFirstDayOfWeek interface
* @tc.desc get the setFirstDayOfWeek and getFirstDayOfWeek value
*/
it('i18n_calendar_test_1600', 0, function () {
console.log('i18n_calendar_test_1600 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setFirstDayOfWeek(7);
let value = calendar.getFirstDayOfWeek();
console.log('i18n_calendar_test_1600 ' + value);
expect(value).assertEqual(7);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1700
* @tc.name test setFirstDayOfWeek with 8 param and getFirstDayOfWeek interface
* @tc.desc get the setFirstDayOfWeek and getFirstDayOfWeek value
*/
it('i18n_calendar_test_1700', 0, function () {
console.log('i18n_calendar_test_1700 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setFirstDayOfWeek(8);
let value = calendar.getFirstDayOfWeek();
console.log('i18n_calendar_test_1700 ' + value);
expect(value).assertEqual(1);
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1800
* @tc.name test setTimeZone and getTimeZone interface
* @tc.desc get the setTimeZone and getTimeZone value
*/
it('i18n_calendar_test_1800', 0, function () {
console.log('i18n_calendar_test_1800 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setTimeZone('Asia/Shanghai');
let value = calendar.getTimeZone();
console.log('i18n_calendar_test_1800 ' + value);
expect(value).assertEqual('China Standard Time');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_1900
* @tc.name test setTimeZone with AAA param and getTimeZone interface
* @tc.desc get the setTimeZone and getTimeZone value
*/
it('i18n_calendar_test_1900', 0, function () {
console.log('i18n_calendar_test_1900 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setTimeZone('AAA');
let value = calendar.getTimeZone();
console.log('i18n_calendar_test_1900 ' + value);
expect(value).assertEqual('GMT');
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2000
* @tc.name test set interface
* @tc.desc get the set value
*/
it('i18n_calendar_test_2000', 0, function () {
console.log('i18n_calendar_test_2000 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.set(2021, 11, 11);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2000 ' + value);
expect(value).assertTrue();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2100
* @tc.name test set interface with hour,minute,second param
* @tc.desc get the set value
*/
it('i18n_calendar_test_2100', 0, function () {
console.log('i18n_calendar_test_2100 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.set(2021, 11, 11, 10, 10, 10);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2100 ' + value);
expect(value).assertTrue();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2200
* @tc.name test set interface with hour,minute param
* @tc.desc get the set value
*/
it('i18n_calendar_test_2200', 0, function () {
console.log('i18n_calendar_test_2200 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.set(2021, 11, 11, 10, 10);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2200 ' + value);
expect(value).assertTrue();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2300
* @tc.name test setTime interface with date param
* @tc.desc get the setTime value
*/
it('i18n_calendar_test_2300', 0, function () {
console.log('i18n_calendar_test_2300 ' + 'start');
let calendar = I18n.getCalendar('zh');
//actuall month is 9
let date1 = new Date(2021, 8, 8, 8, 8, 8, 8);
calendar.setTime(date1);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2300 ' + value);
expect(value).assertFalse();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2400
* @tc.name test setTime interface with wrong month param
* @tc.desc get the setTime value
*/
it('i18n_calendar_test_2400', 0, function () {
console.log('i18n_calendar_test_2400 ' + 'start');
let calendar = I18n.getCalendar('zh');
let date1 = new Date(2021, 18, 8, 8, 8, 8, 8);
calendar.setTime(date1);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2400 ' + value);
expect(value).assertFalse();
})
/**
* @tc.number SUB_GLOBAL_I18N_CALENDAR_JS_2500
* @tc.name test setTime interface
* @tc.desc get the setTime value
*/
it('i18n_calendar_test_2500', 0, function () {
console.log('i18n_calendar_test_2500 ' + 'start');
let calendar = I18n.getCalendar('zh');
calendar.setTime(10540800000);
let value = calendar.isWeekend();
console.log('i18n_calendar_test_2500 ' + value);
expect(value).assertTrue();
})
console.log('*************end CalendarInI18nTest*************');
})}
......@@ -2300,184 +2300,6 @@ describe('I18nTest', function () {
expect(value).assertEqual('1,000米');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0100
* @tc.name test current interface
* @tc.desc check the current result
*/
it('i18n_test_iterator_0100', 0, function () {
console.log('i18n_test_iterator_0100 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.current();
console.log('i18n_test_iterator_0100 ' + value);
expect(value).assertEqual(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0200
* @tc.name test first interface
* @tc.desc check the first
*/
it('i18n_test_iterator_0200', 0, function () {
console.log('i18n_test_iterator_0200 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.first();
console.log('i18n_test_iterator_0200 ' + value);
expect(value).assertEqual(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0300
* @tc.name test last interface
* @tc.desc check the last interface
*/
it('i18n_test_iterator_0300', 0, function () {
console.log('i18n_test_iterator_0300 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.last();
console.log('i18n_test_iterator_0300 ' + value);
expect(value).assertEqual(40);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0400
* @tc.name test next interface
* @tc.desc check the next interface
*/
it('i18n_test_iterator_0400', 0, function () {
console.log('i18n_test_iterator_0400 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.next();
console.log('i18n_test_iterator_0400 ' + value);
expect(value).assertEqual(3);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0500
* @tc.name test next interface with param
* @tc.desc check the next interface with param
*/
it('i18n_test_iterator_0500', 0, function () {
console.log('i18n_test_iterator_0500 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.next(2);
console.log('i18n_test_iterator_0500 ' + value);
expect(value).assertEqual(8);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0600
* @tc.name test previous interface
* @tc.desc check the previous interface
*/
it('i18n_test_iterator_0600', 0, function () {
console.log('i18n_test_iterator_0600 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.previous();
console.log('i18n_test_iterator_0600 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0700
* @tc.name test following interface
* @tc.desc check the following interface
*/
it('i18n_test_iterator_0700', 0, function () {
console.log('i18n_test_iterator_0700 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.following(1);
console.log('i18n_test_iterator_0700 ' + value);
expect(value).assertEqual(3);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0800
* @tc.name test getLineBreakText interface
* @tc.desc check the getLineBreakText interface
*/
it('i18n_test_iterator_0800', 0, function () {
console.log('i18n_test_iterator_0800 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.getLineBreakText();
console.log('i18n_test_iterator_0800 ' + value);
expect(value).assertEqual('My name is Tom.Welcome to the sky world.');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_0900
* @tc.name test isBoundary interface
* @tc.desc check the isBoundary interface
*/
it('i18n_test_iterator_0900', 0, function () {
console.log('i18n_test_iterator_0900 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
let value = iterator.isBoundary(10);
console.log('i18n_test_iterator_0900 ' + value);
expect(value).assertFalse();
// current
let current = iterator.current();
console.log('i18n_test_iterator_0900 ' + current);
expect(current).assertEqual(11);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_BREAKITERATOR_1000
* @tc.name test iterator interface
* @tc.desc check the iterator interface
*/
it('i18n_test_iterator_1000', 0, function () {
console.log('i18n_test_iterator_1000 ' + 'start');
let iterator =I18n.getLineInstance('en');
iterator.setLineBreakText('My name is Tom.Welcome to the sky world.');
// current
let current = iterator.current();
console.log('i18n_test_iterator_1000 ' + current);
expect(current).assertEqual(0);
// next
let next = iterator.next();
console.log('i18n_test_iterator_1000 ' + next);
expect(next).assertEqual(3);
// current
let current2 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current2);
expect(current2).assertEqual(3);
// next 5
let next2 = iterator.next(5);
console.log('i18n_test_iterator_1000 ' + next2);
expect(next2).assertEqual(30);
// previous
let previous = iterator.previous();
console.log('i18n_test_iterator_1000 ' + previous);
expect(previous).assertEqual(26);
// following 2
let follwoing = iterator.following(3);
console.log('i18n_test_iterator_1000 ' + follwoing);
expect(follwoing).assertEqual(8);
// current
let current3 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current3);
expect(current3).assertEqual(8);
// isBoundary
let value = iterator.isBoundary(3);
console.log('i18n_test_iterator_1000 ' + value);
expect(value).assertTrue();
// current
let current4 = iterator.current();
console.log('i18n_test_iterator_1000 ' + current4);
expect(current4).assertEqual(3);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_INDEXUTIL_0100
* @tc.name test getIndex interface
......
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function I18nUtilInI18nTest() {
describe('I18nUtilInI18nTest', function () {
console.log('*************start I18nUtilInI18nTest*************');
let hour = I18n.System.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in I18n.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case in I18n.');
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0100
* @tc.name test unitConvert interface from cup to liter unit with long style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0100', 0, function () {
console.log('i18n_i18nutil_test_0100 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'long');
console.log('i18n_i18nutil_test_0100 ' + value);
expect(value).assertEqual('236.588 liters');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0200
* @tc.name test unitConvert interface from cup to liter unit with undefined style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0200', 0, function () {
console.log('i18n_i18nutil_test_0200 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
undefined);
console.log('i18n_i18nutil_test_0200 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0300
* @tc.name test unitConvert interface from cup to liter unit with null style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0300', 0, function () {
console.log('i18n_i18nutil_test_0300 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
null);
console.log('i18n_i18nutil_test_0300 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0400
* @tc.name test unitConvert interface from cup to liter unit with medium style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0400', 0, function () {
console.log('i18n_i18nutil_test_0400 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'medium');
console.log('i18n_i18nutil_test_0400 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0500
* @tc.name test unitConvert interface from cup to liter unit with narrow style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0500', 0, function () {
console.log('i18n_i18nutil_test_0500 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'narrow');
console.log('i18n_i18nutil_test_0500 ' + value);
expect(value).assertEqual('236.588L');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0600
* @tc.name test unitConvert interface from cup to liter unit with short style
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0600', 0, function () {
console.log('i18n_i18nutil_test_0600 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'short');
console.log('i18n_i18nutil_test_0600 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0700
* @tc.name test unitConvert interface from meter to mile unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0700', 0, function () {
console.log('i18n_i18nutil_test_0700 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'mile', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_0700 ' + value);
expect(value).assertEqual('0.621英里');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0800
* @tc.name test unitConvert interface from hour to second unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0800', 0, function () {
console.log('i18n_i18nutil_test_0800 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'hour', measureSystem: 'SI'},
{unit: 'second', measureSystem: 'SI'},
10,
'zh-CN',
'medium');
console.log('i18n_i18nutil_test_0800 ' + value);
expect(value).assertEqual('36,000秒');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_0900
* @tc.name test unitConvert interface from celsius to fahrenheit unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_0900', 0, function () {
console.log('i18n_i18nutil_test_0900 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'celsius', measureSystem: 'SI'},
{unit: 'fahrenheit', measureSystem: 'SI'},
1000,
'zh-CN',
'short');
console.log('i18n_i18nutil_test_0900 ' + value);
expect(value).assertEqual('1,832°F');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1000
* @tc.name test unitConvert interface from acre to hectare unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1000', 0, function () {
console.log('i18n_i18nutil_test_1000 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'acre', measureSystem: 'SI'},
{unit: 'hectare', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1000 ' + value);
expect(value).assertEqual('404.686公顷');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1100
* @tc.name test unitConvert interface from acre to square-meter unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1100', 0, function () {
console.log('i18n_i18nutil_test_1100 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'acre', measureSystem: 'SI'},
{unit: 'square-meter', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1100 ' + value);
expect(value).assertEqual('4,046,856.422平方米');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1200
* @tc.name test unitConvert interface from kilometer-per-hour to knot unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1200', 0, function () {
console.log('i18n_i18nutil_test_1200 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'kilometer-per-hour', measureSystem: 'SI'},
{unit: 'knot', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1200 ' + value);
expect(value).assertEqual('539.957节');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1300
* @tc.name test unitConvert interface from kilometer-per-hour to meter-per-second unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1300', 0, function () {
console.log('i18n_i18nutil_test_1300 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'kilometer-per-hour', measureSystem: 'SI'},
{unit: 'meter-per-second', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1300 ' + value);
expect(value).assertEqual('每秒277.778米');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1400
* @tc.name test unitConvert interface from meter to kilometer unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1400', 0, function () {
console.log('i18n_i18nutil_test_1400 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'kilometer', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1400 ' + value);
expect(value).assertEqual('1公里');
})
/**
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1500
* @tc.name test unitConvert interface from meter to meter-per-second unit
* @tc.desc get the unitConvert value
*/
it('i18n_i18nutil_test_1500', 0, function () {
console.log('i18n_i18nutil_test_1500 ' + 'start');
let value = I18n.I18NUtil.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'meter-per-second', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_i18nutil_test_1500 ' + value);
expect(value).assertEqual('1,000米');
})
/* *
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1600
* @tc.name test getDateOrder method with zh param
* @tc.desc get the DateOrder value
*/
it('i18n_i18nutil_test_1600', 0, function () {
console.log('i18n_i18nutil_test_1600 ' + 'start');
let value = I18n.I18NUtil.getDateOrder('zh');
console.log('i18n_i18nutil_test_1600 ' + value);
expect(value).assertEqual('y-L-d');
})
/* *
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1700
* @tc.name test getDateOrder method with en param
* @tc.desc get the DateOrder value
*/
it('i18n_i18nutil_test_1700', 0, function () {
console.log('i18n_i18nutil_test_1700 ' + 'start');
let value = I18n.I18NUtil.getDateOrder('en');
console.log('i18n_i18nutil_test_1700 ' + value);
expect(value).assertEqual('LLL-d-y');
})
/* *
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1800
* @tc.name test getDateOrder method with th param
* @tc.desc get the DateOrder value
*/
it('i18n_i18nutil_test_1800', 0, function () {
console.log('i18n_i18nutil_test_1800 ' + 'start');
let value = I18n.I18NUtil.getDateOrder('th');
console.log('i18n_i18nutil_test_1800 ' + value);
expect(value).assertEqual('d-LLL-y');
})
/* *
* @tc.number SUB_GLOBAL_I18N_I18NUTIL_JS_1900
* @tc.name test getDateOrder method with jp param
* @tc.desc get the DateOrder value
*/
it('i18n_i18nutil_test_1900', 0, function () {
console.log('i18n_i18nutil_test_1900 ' + 'start');
let value = I18n.I18NUtil.getDateOrder('jp');
console.log('i18n_i18nutil_test_1900 ' + value);
expect(value).assertEqual('LLL-d-y');
})
console.log('*************end I18nUtilInI18nTest*************');
})}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function IndexUtilInI18nTest() {
describe('IndexUtilInI18nTest', function () {
console.log('*************start IndexUtilInI18nTest*************');
let hour = I18n.System.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in I18n.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case in I18n.');
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_INDEXUTIL_0100
* @tc.name test getIndex interface
* @tc.desc check the getIndex interface
*/
it('i18n_test_indexutil_0100', 0, function () {
console.log('i18n_test_indexutil_0100 ' + 'start');
let index = I18n.getInstance();
let value = index.getIndex('a');
console.log('i18n_test_indexutil_0100 ' + value);
expect(value).assertEqual('A');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_INDEXUTIL_0200
* @tc.name test getIndexList interface
* @tc.desc check the getIndexList interface
*/
it('i18n_test_indexutil_0200', 0, function () {
console.log('i18n_test_indexutil_0200 ' + 'start');
let index = I18n.getInstance();
let value = index.getIndexList();
let len = value.length;
console.log('i18n_test_indexutil_0200 ' + value);
expect(len).assertLarger(0);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_INDEXUTIL_0300
* @tc.name test addLocale interface
* @tc.desc check the addLocale interface
*/
it('i18n_test_indexutil_0300', 0, function () {
console.log('i18n_test_indexutil_0300 ' + 'start');
let index = I18n.getInstance();
index.addLocale('en');
let value = index.getIndex('a');
console.log('i18n_test_indexutil_0300 ' + value);
expect(value).assertEqual('A');
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_INDEXUTIL_0400
* @tc.name test getInstance interface with zh locale
* @tc.desc check the getInstance interface with zh locale
*/
it('i18n_test_indexutil_0400', 0, function () {
console.log('i18n_test_indexutil_0400 ' + 'start');
let index = I18n.getInstance('zh');
let value = index.getIndex('z');
console.log('i18n_test_indexutil_0400 ' + value);
expect(value).assertEqual('Z');
})
console.log('*************end IndexUtilInI18nTest*************');
})}
......@@ -12,13 +12,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import BreakIteratorInI18nTest from './BreakIteratorInI18n.test.js'
import CalendarInI18nTest from './CalendarInI18n.test.js'
import I18nTest from './I18n.test.js'
import I18nUtilInI18nTest from './I18nUtilInI18n.test.js'
import IndexUtilInI18nTest from './IndexUtilInI18n.test.js'
import intlTest from './Intl.test.js'
import PhoneNumberFormatInI18nTest from './PhoneNumberFormatInI18n.test.js'
import LangTest from './Lang.test.js'
import SystemInI18nTest from './SystemInI18n.test.js'
import UtilInI18nTest from './UtilInI18n.test.js'
export default function testsuite() {
BreakIteratorInI18nTest()
CalendarInI18nTest()
I18nTest()
I18nUtilInI18nTest()
IndexUtilInI18nTest()
intlTest()
PhoneNumberFormatInI18nTest()
LangTest()
SystemInI18nTest()
UtilInI18nTest()
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import I18n from '@ohos.i18n'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function UtilInI18nTest() {
describe('UtilInI18nTest', function () {
console.log('*************start UtilInI18nTest*************');
let hour = I18n.System.is24HourClock();
console.log('init 24 hour clock value ' + hour);
/* *
* execute this step before all testcases
*/
beforeAll(function(){
console.log('step before all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/* *
* execute this step before every testcase
*/
beforeEach(function(){
console.log('step before every case in I18n.');
})
/* *
* execute this step after every testcase
*/
afterEach(function(){
console.log('step after every case in I18n.');
})
/* *
* execute this step after all testcases
*/
afterAll(function(){
console.log('step after all cases in I18n.'
+ ' 24hour: ' + I18n.System.is24HourClock()
+ ' prelang: ' + I18n.System.getPreferredLanguageList()
+ ' syslocale: ' + I18n.System.getSystemLocale());
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0100
* @tc.name test unitConvert interface from cup to liter unit with long style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0100', 0, function () {
console.log('i18n_util_test_0100 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'long');
console.log('i18n_util_test_0100 ' + value);
expect(value).assertEqual('236.588 liters');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0200
* @tc.name test unitConvert interface from cup to liter unit with undefined style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0200', 0, function () {
console.log('i18n_util_test_0200 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
undefined);
console.log('i18n_util_test_0200 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0300
* @tc.name test unitConvert interface from cup to liter unit with null style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0300', 0, function () {
console.log('i18n_util_test_0300 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
null);
console.log('i18n_util_test_0300 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0400
* @tc.name test unitConvert interface from cup to liter unit with medium style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0400', 0, function () {
console.log('i18n_util_test_0400 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'medium');
console.log('i18n_util_test_0400 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0500
* @tc.name test unitConvert interface from cup to liter unit with narrow style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0500', 0, function () {
console.log('i18n_util_test_0500 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'narrow');
console.log('i18n_util_test_0500 ' + value);
expect(value).assertEqual('236.588L');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0600
* @tc.name test unitConvert interface from cup to liter unit with short style
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0600', 0, function () {
console.log('i18n_util_test_0600 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'cup', measureSystem: 'US'},
{unit: 'liter', measureSystem: 'SI'},
1000,
'en-US',
'short');
console.log('i18n_util_test_0600 ' + value);
expect(value).assertEqual('236.588 L');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0700
* @tc.name test unitConvert interface from meter to mile unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0700', 0, function () {
console.log('i18n_util_test_0700 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'mile', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_0700 ' + value);
expect(value).assertEqual('0.621英里');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0800
* @tc.name test unitConvert interface from hour to second unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0800', 0, function () {
console.log('i18n_util_test_0800 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'hour', measureSystem: 'SI'},
{unit: 'second', measureSystem: 'SI'},
10,
'zh-CN',
'medium');
console.log('i18n_util_test_0800 ' + value);
expect(value).assertEqual('36,000秒');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_0900
* @tc.name test unitConvert interface from celsius to fahrenheit unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_0900', 0, function () {
console.log('i18n_util_test_0900 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'celsius', measureSystem: 'SI'},
{unit: 'fahrenheit', measureSystem: 'SI'},
1000,
'zh-CN',
'short');
console.log('i18n_util_test_0900 ' + value);
expect(value).assertEqual('1,832°F');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1000
* @tc.name test unitConvert interface from acre to hectare unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1000', 0, function () {
console.log('i18n_util_test_1000 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'acre', measureSystem: 'SI'},
{unit: 'hectare', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1000 ' + value);
expect(value).assertEqual('404.686公顷');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1100
* @tc.name test unitConvert interface from acre to square-meter unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1100', 0, function () {
console.log('i18n_util_test_1100 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'acre', measureSystem: 'SI'},
{unit: 'square-meter', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1100 ' + value);
expect(value).assertEqual('4,046,856.422平方米');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1200
* @tc.name test unitConvert interface from kilometer-per-hour to knot unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1200', 0, function () {
console.log('i18n_util_test_1200 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'kilometer-per-hour', measureSystem: 'SI'},
{unit: 'knot', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1200 ' + value);
expect(value).assertEqual('539.957节');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1300
* @tc.name test unitConvert interface from kilometer-per-hour to meter-per-second unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1300', 0, function () {
console.log('i18n_util_test_1300 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'kilometer-per-hour', measureSystem: 'SI'},
{unit: 'meter-per-second', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1300 ' + value);
expect(value).assertEqual('每秒277.778米');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1400
* @tc.name test unitConvert interface from meter to kilometer unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1400', 0, function () {
console.log('i18n_util_test_1400 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'kilometer', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1400 ' + value);
expect(value).assertEqual('1公里');
})
/**
* @tc.number SUB_GLOBAL_I18N_UTIL_JS_1500
* @tc.name test unitConvert interface from meter to meter-per-second unit
* @tc.desc get the unitConvert value
*/
it('i18n_util_test_1500', 0, function () {
console.log('i18n_util_test_1500 ' + 'start');
let util = new I18n.Util();
let value = util.unitConvert({unit: 'meter', measureSystem: 'SI'},
{unit: 'meter-per-second', measureSystem: 'SI'},
1000,
'zh-CN',
'long');
console.log('i18n_util_test_1500 ' + value);
expect(value).assertEqual('1,000米');
})
console.log('*************end UtilInI18nTest*************');
})}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册