提交 3689ecc2 编写于 作者: O openharmony_ci 提交者: Gitee

!1198 修改process和util的XTS用例

Merge pull request !1198 from clearme777/master
......@@ -1757,4 +1757,884 @@ describe('ChildProcessTest', function () {
var offtest = process.off("add")
expect(offtest).assertEqual(true)
})
/**
* @tc.name: testTid001
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid001', 0, function () {
var pres = Process.tid
console.info('test press value:' + pres)
if(pres > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testTid002
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid002', 0, function () {
for(var i=0; i<3; i++)
{
var pres = Process.tid
if(pres > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testTid003
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid003', 0, function () {
for(var i=0; i<8; i++)
{
var pres = Process.tid
if(pres > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testTid004
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid004', 0, function () {
for(var i=0; i<18; i++)
{
var pres = Process.tid
if(pres > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testTid005
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid005', 0, function () {
for(var i=0; i<26; i++)
{
var pres = Process.tid
if(pres > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testIsisolatedProcess001
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess001', 0, function () {
var pres = Process.isIsolatedProcess()
expect(pres).assertEqual(true)
})
/**
* @tc.name: testIsisolatedProcess002
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess002', 0, function () {
for(var i=0; i<3; i++)
{
var pres =Process.isIsolatedProcess()
expect(pres).assertEqual(true)
}
})
/**
* @tc.name: testIsisolatedProcess003
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess003', 0, function () {
for(var i=0; i<18; i++)
{
var pres =Process.isIsolatedProcess()
expect(pres).assertEqual(true)
}
})
/**
* @tc.name: testIsisolatedProcess004
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess004', 0, function () {
for(var i=0; i<20; i++)
{
var pres =Process.isIsolatedProcess()
expect(pres).assertEqual(true)
}
})
/**
* @tc.name: testIsisolatedProcess005
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess005', 0, function () {
for(var i=0; i<25; i++)
{
var pres =Process.isIsolatedProcess()
expect(pres).assertEqual(true)
}
})
/**
* @tc.name: testIsappuid001
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid001', 0, function () {
var isorno = Process.isAppUid(456)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid002
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid002', 0, function () {
var isorno = Process.isAppUid(123)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid003
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid003', 0, function () {
var isorno = Process.isAppUid(80000)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid004
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid004', 0, function () {
var isorno = Process.isAppUid(789)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid005
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid005', 0, function () {
var isorno = Process.isAppUid(8569)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIs64Bit001
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit001', 0, function () {
var isorno = Process.is64Bit()
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIs64Bit002
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit002', 0, function () {
for(var i=0; i<3; i++)
{
var isorno = Process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testIs64Bit003
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit003', 0, function () {
for(var i=0; i<15; i++)
{
var isorno = Process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testIs64Bit004
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit004', 0, function () {
for(var i=0; i<18; i++)
{
var isorno = Process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testIs64Bit005
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit005', 0, function () {
for(var i=0; i<22; i++)
{
var isorno = Process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testGetuidforname001
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname001',0, function () {
var pres = Process.getUidForName("1111")
expect(pres).assertEqual(-1)
})
/**
* @tc.name: testGetuidforname002
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname002', 0, function () {
for(var i=0; i<3; i++)
{
var pres = Process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetuidforname003
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname003', 0, function () {
for(var i=0; i<18; i++)
{
var pres = Process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetuidforname004
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname004', 0, function () {
for(var i=0; i<16; i++)
{
var pres = Process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetuidforname005
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname005', 0, function () {
for(var i=0; i<21; i++)
{
var pres = Process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetthreadpriority001
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority001', 0, function () {
var pres = Process.tid
var pri = Process.getThreadPriority(pres)
if(pri)
{
var flag = true
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetthreadpriority002
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority002', 0, function () {
var pres = Process.tid
for(var i=0; i<3; i++)
{
var pri = Process.getThreadPriority(pres)
if(pri > 0)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetthreadpriority003
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority003', 0, function () {
var pres = Process.tid
for(var i=0; i<16; i++)
{
var pri = Process.getThreadPriority(pres)
if(pri > 0)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetthreadpriority004
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority004', 0, function () {
var pres = Process.tid
for(var i=0; i<18; i++)
{
var pri = Process.getThreadPriority(pres)
if(pri > 0)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetthreadpriority005
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority005', 0, function () {
var pres = Process.tid
for(var i=0; i<25; i++)
{
var pri = Process.getThreadPriority(pres)
if(pri > 0)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetstartrealtime001
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime001', 0, function () {
for(var i=0; i<3; i++)
{
var pri = Process.getStartRealtime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetstartrealtime002
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime002', 0, function () {
var pri = Process.getStartRealtime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetstartrealtime003
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime003', 0, function () {
for(var i=0; i<16; i++)
{
var pri = Process.getStartRealtime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetstartrealtime004
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime004', 0, function () {
for(var i=0; i<19; i++)
{
var pri = Process.getStartRealtime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetstartrealtime005
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime005', 0, function () {
for(var i=0; i<22; i++)
{
var pri = Process.getStartRealtime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime001
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime001', 0, function () {
for(var i=0; i<3; i++)
{
var pri = Process.getPastCputime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime002
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime002', 0, function () {
var pri = Process.getPastCputime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetpastCputime003
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime003', 0, function () {
for(var i=0; i<12; i++)
{
var pri = Process.getPastCputime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime004
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime004', 0, function () {
for(var i=0; i<16; i++)
{
var pri = Process.getPastCputime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime005
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime005', 0, function () {
for(var i=0; i<21; i++)
{
var pri = Process.getPastCputime()
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig001
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig001', 0, function () {
var _SC_ARG_MAX = 0
var pri = Process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetSystemConfig002
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig002', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<3; i++)
{
var pri = Process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig003
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig003', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<8; i++)
{
var pri = Process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig004
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig004', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<15; i++)
{
var pri = Process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig005
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig005', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<19; i++)
{
var pri = Process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetAvailableCores001
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores001', 0, function () {
var pri = Process.getAvailableCores()
if(pri != null)
{
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetAvailableCores002
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores002', 0, function () {
for(var i=0; i<3; i++)
{
var pri = Process.getAvailableCores()
if(pri != 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetAvailableCores003
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores003', 0, function () {
for(var i=0; i<9; i++)
{
var pri = Process.getAvailableCores()
if(pri != 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetAvailableCores004
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores004', 0, function () {
for(var i=0; i<12; i++)
{
var pri = Process.getAvailableCores()
if(pri != 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetAvailableCores005
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores005', 0, function () {
for(var i=0; i<18; i++)
{
var pri = Process.getAvailableCores()
if(pri != 0)
{
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetEnvironmentVar001
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar001', 0, function () {
var pri = Process.getEnvironmentVar("USER")
if(pri != null) {
var flag = true
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetEnvironmentVar002
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar002', 0, function () {
for(var i=0; i<3; i++)
{
var pri = Process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar003
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar003', 0, function () {
for(var i=0; i<15; i++)
{
var pri = Process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar004
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar004', 0, function () {
for(var i=0; i<26; i++)
{
var pri = Process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar005
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar005', 0, function () {
for(var i=0; i<19; i++)
{
var pri = Process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = true
expect(flag).assertEqual(true)
}
}
})
})
\ No newline at end of file
/*
* Copyright (C) 2021 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.
*/
* Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import util from '@ohos.util'
class Temperature {
constructor(value) {
this._temp = value;
}
compareTo(value) {
return this._temp >= value.getTemp();
}
getTemp() {
return this._temp;
}
toString() {
return this._temp.toString();
}
}
var tempLower = new Temperature(30);
var tempUpper = new Temperature(40);
var tempLess = new Temperature(20);
var tempMiDF = new Temperature(35);
var tempMidS = new Temperature(39);
var tempMore = new Temperature(45);
var range = new util.Scope(tempLower, tempUpper);
var rangeFir = new util.Scope(tempMiDF, tempMidS);
var rangeSec = new util.Scope(tempLess, tempMore);
var rangeThi = new util.Scope(tempLess, tempMiDF);
var rangeFif = new util.Scope(tempMiDF, tempMore);
describe('TextEncoderTest', function () {
/**
......@@ -678,7 +706,7 @@ describe('TextEncoderTest', function () {
var re = BOM + rel
expect(retStr).assertEqual(re)
})
/**
* @tc.name: testGetEncoding001
* @tc.desc: Encoding format.
......@@ -931,4 +959,3810 @@ describe('TextEncoderTest', function () {
expect(result.read).assertEqual(0)
expect(result.written).assertEqual(0)
})
* @tc.name: testGetLower001
* @tc.desc: Obtains the lower bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetLower001', 0, function () {
var result = range.getLower()
console.info('test result =' + result)
expect(+result).assertEqual(30)
})
/**
* @tc.name: testGetLower002
* @tc.desc: Obtains the lower bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetLower002', 0, function () {
var result = rangeFir.getLower()
expect(+result).assertEqual(35)
})
/**
* @tc.name: testGetLower003
* @tc.desc: Obtains the lower bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetLower003', 0, function () {
var result = rangeSec.getLower()
expect(+result).assertEqual(20)
})
/**
* @tc.name: testGetLower004
* @tc.desc: Obtains the lower bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetLower004', 0, function () {
var result = rangeThi.getLower()
expect(+result).assertEqual(20)
})
/**
* @tc.name: testGetLower005
* @tc.desc: Obtains the lower bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetLower005', 0, function () {
var result = rangeFif.getLower()
expect(+result).assertEqual(35)
})
/**
* @tc.name: testGetUpper001
* @tc.desc: Obtains the upper bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetUpper001', 0, function () {
var result = range.getUpper()
expect(+result).assertEqual(40)
})
/**
* @tc.name: testGetUpper002
* @tc.desc: Obtains the upper bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetUpper002', 0, function () {
var result = rangeFir.getUpper()
expect(+result).assertEqual(39)
})
/**
* @tc.name: testGetUpper003
* @tc.desc: Obtains the upper bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetUpper003', 0, function () {
var result = rangeSec.getUpper()
expect(+result).assertEqual(45)
})
/**
* @tc.name: testGetUpper004
* @tc.desc: Obtains the upper bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetUpper004', 0, function () {
var result = rangeThi.getUpper()
expect(+result).assertEqual(35)
})
/**
* @tc.name: testGetUpper005
* @tc.desc: Obtains the upper bound of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testGetUpper005', 0, function () {
var result = rangeFif.getUpper()
expect(+result).assertEqual(45)
})
/**
* @tc.name: testClamp001
* @tc.desc: Clamps a given value to the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testClamp001', 0, function () {
var result =range.clamp(tempLess)
expect(+result).assertEqual(30)
})
/**
* @tc.name: testClamp002
* @tc.desc: Clamps a given value to the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testClamp002', 0, function () {
var result =range.clamp(tempMiDF)
expect(+result).assertEqual(35)
})
/**
* @tc.name: testClamp003
* @tc.desc: Clamps a given value to the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testClamp003', 0, function () {
var result =range.clamp(tempMore)
expect(+result).assertEqual(40)
})
/**
* @tc.name: testClamp004
* @tc.desc: Clamps a given value to the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testClamp004', 0, function () {
var result =range.clamp(tempLower)
expect(+result).assertEqual(30)
})
/**
* @tc.name: testClamp005
* @tc.desc: Clamps a given value to the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testClamp005', 0, function () {
var result =range.clamp(tempUpper)
expect(+result).assertEqual(40)
})
/**
* @tc.name: testContains001
* @tc.desc: Checks whether a given value is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains001', 0, function () {
var result = range.contains(tempLess)
expect(result).assertEqual(false)
})
/**
* @tc.name: testContains002
* @tc.desc: Checks whether a given value is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains002', 0, function () {
var result = range.contains(tempMiDF)
expect(result).assertEqual(true)
})
/**
* @tc.name: testContains003
* @tc.desc: Checks whether a given value is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains003', 0, function () {
var result = range.contains(tempMore)
expect(result).assertEqual(false)
})
/**
* @tc.name: testContains004
* @tc.desc: Checks whether a given value is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains004', 0, function () {
var result = range.contains(tempLower)
expect(result).assertEqual(true)
})
/**
* @tc.name: testContains005
* @tc.desc: Checks whether a given value is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains005', 0, function () {
var result = range.contains(tempUpper)
expect(result).assertEqual(true)
})
/**
* @tc.name: testContains001
* @tc.desc: Checks whether a given range is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains001', 0, function () {
var result = range.contains(rangeFir)
expect(result).assertEqual(true)
})
/**
* @tc.name: testContains002
* @tc.desc: Checks whether a given range is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains002', 0, function () {
var result = range.contains(rangeSec)
expect(result).assertEqual(false)
})
/**
* @tc.name: testContains003
* @tc.desc: Checks whether a given range is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains003', 0, function () {
var result = range.contains(rangeThi)
expect(result).assertEqual(false)
})
/**
* @tc.name: testContains004
* @tc.desc: Checks whether a given range is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains004', 0, function () {
var result = range.contains(rangeFif)
expect(result).assertEqual(false)
})
/**
* @tc.name: testContains005
* @tc.desc: Checks whether a given range is within the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testContains005', 0, function () {
var result = range.contains(range)
expect(result).assertEqual(true)
})
/**
* @tc.name: testExpand001
* @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand001', 0, function () {
var result = range.expand(tempMiDF, tempMidS)
// console.info('test result type =' + Object.prototype.toString.call(result))
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand002
* @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand002', 0, function () {
var result = range.expand(tempLess, tempMore)
expect(result + '').assertEqual('[20, 45]')
})
/**
* @tc.name: testExpand003
* @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand003', 0, function () {
var result = range.expand(tempLess, tempMiDF)
expect(result + '').assertEqual('[20, 40]')
})
/**
* @tc.name: testExpand004
* @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand004', 0, function () {
var result = range.expand(tempMiDF, tempMore)
expect(result + '').assertEqual('[30, 45]')
})
/**
* @tc.name: testExpand005
* @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand005', 0, function () {
var result = range.expand(tempLower, tempUpper)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand001
* @tc.desc: Creates the smallest range that includes the current range and a given range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand001', 0, function () {
var result = range.expand(rangeFir)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand002
* @tc.desc: Creates the smallest range that includes the current range and a given range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand002', 0, function () {
var result = range.expand(rangeSec)
expect(result + '').assertEqual('[20, 45]')
})
/**
* @tc.name: testExpand003
* @tc.desc: Creates the smallest range that includes the current range and a given range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand003', 0, function () {
var result = range.expand(rangeThi)
expect(result + '').assertEqual('[20, 40]')
})
/**
* @tc.name: testExpand004
* @tc.desc: Creates the smallest range that includes the current range and a given range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand004', 0, function () {
var result = range.expand(rangeFif)
expect(result + '').assertEqual('[30, 45]')
})
/**
* @tc.name: testExpand005
* @tc.desc: Creates the smallest range that includes the current range and a given range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand005', 0, function () {
var result = range.expand(range)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand001
* @tc.desc: Creates the smallest range that includes the current range and a given value.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand001', 0, function () {
var result = range.expand(tempMiDF)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand002
* @tc.desc: Creates the smallest range that includes the current range and a given value.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand002', 0, function () {
var result = range.expand(tempLess)
expect(result + '').assertEqual('[20, 40]')
})
/**
* @tc.name: testExpand003
* @tc.desc: Creates the smallest range that includes the current range and a given value.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand003', 0, function () {
var result = range.expand(tempMore)
expect(result + '').assertEqual('[30, 45]')
})
/**
* @tc.name: testExpand004
* @tc.desc: Creates the smallest range that includes the current range and a given value.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand004', 0, function () {
var result = range.expand(tempLower)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testExpand005
* @tc.desc: Creates the smallest range that includes the current range and a given value.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testExpand005', 0, function () {
var result = range.expand(tempUpper)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testInstersect001
* @tc.desc: Returns the intersection of a given range and the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect001', 0, function () {
var result = range.intersect(rangeFir)
expect(result + '').assertEqual('[35, 39]')
})
/**
* @tc.name: testInstersect002
* @tc.desc: Returns the intersection of a given range and the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect002', 0, function () {
var result = range.intersect(rangeSec)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testInstersect003
* @tc.desc: Returns the intersection of a given range and the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect003', 0, function () {
var result = range.intersect(rangeThi)
expect(result + '').assertEqual('[30, 35]')
})
/**
* @tc.name: testInstersect004
* @tc.desc: Returns the intersection of a given range and the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect004', 0, function () {
var result = range.intersect(rangeFif)
expect(result + '').assertEqual('[35, 40]')
})
/**
* @tc.name: testInstersect005
* @tc.desc: Returns the intersection of a given range and the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect005', 0, function () {
var result = range.intersect(range)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testInstersect001
* @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect001', 0, function () {
var result = range.intersect(tempMiDF, tempMidS)
expect(result + '').assertEqual('[35, 39]')
})
/**
* @tc.name: testInstersect002
* @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect002', 0, function () {
var result = range.intersect(tempLess, tempMore)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testInstersect003
* @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect003', 0, function () {
var result = range.intersect(tempLess, tempMiDF)
expect(result + '').assertEqual('[30, 35]')
})
/**
* @tc.name: testInstersect004
* @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect004', 0, function () {
var result = range.intersect(tempMiDF, tempMore)
expect(result + '').assertEqual('[35, 40]')
})
/**
* @tc.name: testInstersect005
* @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testInstersect005', 0, function () {
var result = range.intersect(tempLower, tempUpper)
expect(result + '').assertEqual('[30, 40]')
})
/**
* @tc.name: testToString001
* @tc.desc: Obtains a string representation of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testToString001', 0, function () {
var result = range.toString()
expect(result).assertEqual('[30, 40]')
})
/**
* @tc.name: testToString002
* @tc.desc: Obtains a string representation of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testToString002', 0, function () {
var result = rangeFir.toString()
expect(result).assertEqual('[35, 39]')
})
/**
* @tc.name: testToString003
* @tc.desc: Obtains a string representation of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testToString003', 0, function () {
var result = rangeSec.toString()
expect(result).assertEqual('[20, 45]')
})
/**
* @tc.name: testToString004
* @tc.desc: Obtains a string representation of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testToString004', 0, function () {
var result = rangeThi.toString()
expect(result).assertEqual('[20, 35]')
})
/**
* @tc.name: testToString005
* @tc.desc: Obtains a string representation of the current range.
* @tc.require: AR000GFB4U
* @tc.author: jiangkai
*/
it('testToString005', 0, function () {
var result = rangeFif.toString()
expect(result).assertEqual('[35, 45]')
})
})
describe('Base64Test', function () {
/**
* @tc.name: testEncode001
* @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncode001', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([115,49,51]);
var rarray = new Uint8Array([99,122,69,122]);
var result = that.encode(array);
for (var i = 0; i < 4; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testEncode002
* @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncode002', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]);
var result = that.encode(array);
for (var i = 0; i < 20; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testEncode003
* @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncode003', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]);
var result = that.encode(array);
for (var i = 0; i < 36; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testEncode004
* @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncode004', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([168, 174, 155, 255]);
var rarray = new Uint8Array([113,75,54,98,47,119,61,61]);
var result = that.encode(array);
for (var i = 0; i < 8; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testEncode005
* @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncode005', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52]);
var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]);
var result = that.encode(array);
for (var i = 0; i <8; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testEncodeToString001
* @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToString001', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([115,49,51]);
var result = that.encodeToString(array)
expect(result).assertEqual('czEz')
})
/**
* @tc.name: testEncodeToString002
* @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToString002', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
var result = that.encodeToString(array);
expect(result).assertEqual('QmFzZTY0IE5vZGUuanM=')
})
/**
* @tc.name: testEncodeToString003
* @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToString003', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
var result = that.encodeToString(array);
expect(result).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=')
})
/**
* @tc.name: testEncodeToString004
* @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToString004', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([168, 174, 155, 255]);
var result = that.encodeToString(array);
expect(result).assertEqual('qK6b/w==')
})
/**
* @tc.name: testEncodeToString005
* @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToString005', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52]);
var result = that.encodeToString(array);
expect(result).assertEqual('QmFzZTY0')
})
/**
* @tc.name: testDecode001
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode001', 0, function () {
var that = new util.Base64()
var buff = 'czEz';
var rarray = new Uint8Array([115,49,51]);
var result = that.decode(buff);
for (var i = 0; i < 3; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode002
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode002', 0, function () {
var that = new util.Base64()
var buff = 'QmFzZTY0IE5vZGUuanM=';
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
var result = that.decode(buff);
for (var i = 0; i < 14; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode003
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode003', 0, function () {
var that = new util.Base64()
var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=';
var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
var result = that.decode(buff);
for (var i = 0; i < 26; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode004
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode004', 0, function () {
var that = new util.Base64()
var buff = 'qK6b/w==';
var rarray = new Uint8Array([168, 174, 155, 255]);
var result = that.decode(buff);
for (var i = 0; i < 4; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode005
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode005', 0, function () {
var that = new util.Base64()
var buff = 'QmFzZTY0';
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]);
var result = that.decode(buff);
for (var i = 0; i <6; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode001
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode001', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([99,122,69,122]);
var rarray = new Uint8Array([115,49,51]);
var result = that.decode(array);
for (var i = 0; i < 3; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode002
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode002', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]);
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
var result = that.decode(array);
for (var i = 0; i < 14; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode003
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode003', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]);
var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
var result = that.decode(array);
for (var i = 0; i < 26; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode004
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode004', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([113,75,54,98,47,119,61,61]);
var rarray = new Uint8Array([168, 174, 155, 255]);
var result = that.decode(array);
for (var i = 0; i < 4; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
/**
* @tc.name: testDecode005
* @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecode005', 0, function () {
var that = new util.Base64()
var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]);
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]);
var result = that.decode(array);
for (var i = 0; i <6; i++) {
expect(result[i]).assertEqual(rarray[i]);
}
})
//base64 EncodeAsync test
/**
* @tc.name: testEncodeAsync001
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeAsync001', 0, async function () {
var that = await new util.Base64();
var array = new Uint8Array([115,49,51]);
var rarray = new Uint8Array([99,122,69,122]);
that.encodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testEncodeAsync002
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeAsync002', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]);
that.encodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testEncodeAsync003
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeAsync003', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]);
that.encodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testEncodeAsync004
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeAsync004', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([168, 174, 155, 255]);
var rarray = new Uint8Array([113,75,54,98,47,119,61,61]);
that.encodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testEncodeAsync005
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeAsync005', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52]);
var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]);
that.encodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testEncodeToStringAsync001
* @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToStringAsync001', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([115,49,51]);
that.encodeToStringAsync(array).then(val=>{
expect(val).assertEqual('czEz')
})
})
/**
* @tc.name: testEncodeToStringAsync002
* @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToStringAsync002', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
that.encodeToStringAsync(array).then(val=>{
expect(val).assertEqual('QmFzZTY0IE5vZGUuanM=')
})
})
/**
* @tc.name: testEncodeToStringAsync003
* @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToStringAsync003', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]);
that.encodeToStringAsync(array).then(val=>{
expect(val).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=')
})
})
/**
* @tc.name: testEncodeToStringAsync004
* @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToStringAsync004', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([168, 174, 155, 255]);
that.encodeToStringAsync(array).then(val=>{
expect(val).assertEqual('qK6b/w==')
})
})
/**
* @tc.name: testEncodeToStringAsync005
* @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testEncodeToStringAsync005', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([66, 97, 115, 101, 54, 52]);
that.encodeToStringAsync(array).then(val=>{
expect(val).assertEqual('QmFzZTY0')
})
})
/**
* @tc.name: testDecodeAsync001
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync001', 0, async function () {
var that = new util.Base64()
var buff = 'czEz';
var array = new Uint8Array([115,49,51]);
that.decodeAsync(buff).then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testDecodeAsync002
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync002', 0, async function () {
var that = new util.Base64()
var buff = 'QmFzZTY0IE5vZGUuanM=';
var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
that.decodeAsync(buff).then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testDecodeAsync003
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync003', 0, async function () {
var that = new util.Base64()
var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=';
var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
that.decodeAsync(buff).then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testDecodeAsync004
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync004', 0, async function () {
var that = new util.Base64()
var buff = 'qK6b/w==';
var array = new Uint8Array([168, 174, 155, 255]);
that.decodeAsync(buff).then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testDecodeAsync005
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync005', 0, async function () {
var that = new util.Base64()
var buff = 'QmFzZTY0';
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]);
that.decodeAsync(buff).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testDecodeAsync001
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync001', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([99,122,69,122]);
var rarray = new Uint8Array([115,49,51]);
that.decodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testDecodeAsync002
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync002', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]);
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]);
that.decodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testDecodeAsync003
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync003', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]);
var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]);
that.decodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testDecodeAsync004
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync004', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([113,75,54,98,47,119,61,61]);
var rarray = new Uint8Array([168, 174, 155, 255]);
that.decodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
/**
* @tc.name: testDecodeAsync005
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array.
* @tc.require: AR000GFB2Q
* @tc.author: bihu
*/
it('testDecodeAsync005', 0, async function () {
var that = new util.Base64()
var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]);
var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]);
that.decodeAsync(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
expect(val[i]).assertEqual(rarray[i])
}
})
})
})
describe('RationalNumberFunTest', function () {
/**
* @tc.name: testRationalNumberCreateRationalFromString001
* @tc.desc: Creates a RationalNumber object based on a given string.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCreateRationalFromString001', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('-1:2')
var result1 = res.value()
expect(result1).assertEqual(-0.5)
})
/**
* @tc.name: testRationalNumberCreateRationalFromString002
* @tc.desc: Creates a RationalNumber object based on a given string.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCreateRationalFromString002', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+3/4')
var result1 = res.value()
expect(result1).assertEqual(0.75)
})
/**
* @tc.name: testRationalNumberCreateRationalFromString003
* @tc.desc: Creates a RationalNumber object based on a given string.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCreateRationalFromString003', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+3:-4')
var result1 = res.value()
expect(result1).assertEqual(-0.75)
})
/**
* @tc.name: testRationalNumberCreateRationalFromString004
* @tc.desc: Creates a RationalNumber object based on a given string.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCreateRationalFromString004', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+2:4')
var result1 = res.value()
expect(result1).assertEqual(0.5)
})
/**
* @tc.name: testRationalNumberCreateRationalFromString005
* @tc.desc: Creates a RationalNumber object based on a given string.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCreateRationalFromString005', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+2:-4')
var result1 = res.value()
expect(result1).assertEqual(-0.5)
})
/**
* @tc.name: testRationalNumberCompare001
* @tc.desc: Compares the current RationalNumber object with a given object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCompare001', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(3, 4)
var res = pro.compareTo(proc)
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberCompare002
* @tc.desc: Compares the current RationalNumber object with a given object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCompare002', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(0, 0)
var res = pro.compareTo(proc)
expect(res).assertEqual(-1)
})
/**
* @tc.name: testRationalNumberCompare003
* @tc.desc: Compares the current RationalNumber object with a given object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCompare003', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(8, 3)
var res = pro.compareTo(proc)
expect(res).assertEqual(-1)
})
/**
* @tc.name: testRationalNumberCompare004
* @tc.desc: Compares the current RationalNumber object with a given object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCompare004', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(2, 1)
var res = pro.compareTo(proc)
expect(res).assertEqual(0)
})
/**
* @tc.name: testRationalNumberCompare005
* @tc.desc: Compares the current RationalNumber object with a given object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberCompare005', 0, function () {
var pro = new util.RationalNumber(0, 0)
var proc = new util.RationalNumber(2, 1)
var res = pro.compareTo(proc)
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberEquals001
* @tc.desc: Checks whether a given object is the same as the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberEquals001', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(3, 4)
var res = pro.equals(proc)
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberEquals002
* @tc.desc: Checks whether a given object is the same as the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberEquals002', 0, function () {
var pro = new util.RationalNumber(2, 1)
var proc = new util.RationalNumber(4, 2)
var res = pro.equals(proc)
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberEquals003
* @tc.desc: Checks whether a given object is the same as the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberEquals003', 0, function () {
var pro = new util.RationalNumber(0, 1)
var proc = new util.RationalNumber(0, 2)
var res = pro.equals(proc)
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberEquals004
* @tc.desc: Checks whether a given object is the same as the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberEquals004', 0, function () {
var pro = new util.RationalNumber(0, 0)
var proc = new util.RationalNumber(0, 2)
var res = pro.equals(proc)
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberEquals005
* @tc.desc: Checks whether a given object is the same as the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberEquals005', 0, function () {
var pro = new util.RationalNumber(-2, 0)
var proc = new util.RationalNumber(2, 0)
var res = pro.equals(proc)
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberValue001
* @tc.desc: Obtains the value of the current RationalNumber object as a number.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberValue001', 0, function () {
var pro = new util.RationalNumber(2, 1)
var res = pro.value()
expect(res).assertEqual(2)
})
/**
* @tc.name: testRationalNumberValue002
* @tc.desc: Obtains the value of the current RationalNumber object as a number.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberValue002', 0, function () {
var pro = new util.RationalNumber(2, 10)
var res = pro.value()
expect(res).assertEqual(0.2)
})
/**
* @tc.name: testRationalNumberValue003
* @tc.desc: Obtains the value of the current RationalNumber object as a number.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberValue003', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.value()
expect(res).assertEqual(0.5)
})
/**
* @tc.name: testRationalNumberValue004
* @tc.desc: Obtains the value of the current RationalNumber object as a number.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberValue004', 0, function () {
var pro = new util.RationalNumber(4, 2)
var res = pro.value()
expect(res).assertEqual(2)
})
/**
* @tc.name: testRationalNumberValue005
* @tc.desc: Obtains the value of the current RationalNumber object as a number.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberValue005', 0, function () {
var pro = new util.RationalNumber(4, 1)
var res = pro.value()
expect(res).assertEqual(4)
})
/**
* @tc.name: testRationalNumberGetCommonDivisor001
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetCommonDivisor001', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.getCommonDivisor(4, 8)
expect(res).assertEqual(4)
})
/**
* @tc.name: testRationalNumberGetCommonDivisor002
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetCommonDivisor002', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.getCommonDivisor(10, 15)
expect(res).assertEqual(5)
})
/**
* @tc.name: testRationalNumberGetCommonDivisor003
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetCommonDivisor003', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.getCommonDivisor(8, 4)
expect(res).assertEqual(4)
})
/**
* @tc.name: testRationalNumberGetCommonDivisor004
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetCommonDivisor004', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.getCommonDivisor(8, 16)
expect(res).assertEqual(8)
})
/**
* @tc.name: testRationalNumberGetCommonDivisor005
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetCommonDivisor005', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.getCommonDivisor(2, 16)
expect(res).assertEqual(2)
})
/**
* @tc.name: testRationalNumberGetDenominator001
* @tc.desc: Obtains the denominator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetDenominator001', 0, function () {
var pro = new util.RationalNumber(2, 1)
var res = pro.getDenominator()
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberGetDenominator002
* @tc.desc: Obtains the denominator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetDenominator002', 0, function () {
var pro = new util.RationalNumber(2, 3)
var res = pro.getDenominator()
expect(res).assertEqual(3)
})
/**
* @tc.name: testRationalNumberGetDenominator003
* @tc.desc: Obtains the denominator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetDenominator003', 0, function () {
var pro = new util.RationalNumber(2, 0)
var res = pro.getDenominator()
expect(res).assertEqual(0)
})
/**
* @tc.name: testRationalNumberGetDenominator004
* @tc.desc: Obtains the denominator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetDenominator004', 0, function () {
var pro = new util.RationalNumber(10, 5)
var res = pro.getDenominator()
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberGetDenominator005
* @tc.desc: Obtains the denominator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetDenominator005', 0, function () {
var pro = new util.RationalNumber(6, 3)
var res = pro.getDenominator()
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberGetNumerator001
* @tc.desc: Obtains the numerator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetNumerator001', 0, function () {
var pro = new util.RationalNumber(-2, 1)
var res = pro.getNumerator()
expect(res).assertEqual(-2)
})
/**
* @tc.name: testRationalNumberGetNumerator002
* @tc.desc: Obtains the numerator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetNumerator002', 0, function () {
var pro = new util.RationalNumber(0, 3)
var res = pro.getNumerator()
expect(res).assertEqual(0)
})
/**
* @tc.name: testRationalNumberGetNumerator003
* @tc.desc: Obtains the numerator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetNumerator003', 0, function () {
var pro = new util.RationalNumber(2, 4)
var res = pro.getNumerator()
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberGetNumerator004
* @tc.desc: Obtains the numerator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetNumerator004', 0, function () {
var pro = new util.RationalNumber(3, 6)
var res = pro.getNumerator()
expect(res).assertEqual(1)
})
/**
* @tc.name: testRationalNumberGetNumerator005
* @tc.desc: Obtains the numerator of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberGetNumerator005', 0, function () {
var pro = new util.RationalNumber(10, 5)
var res = pro.getNumerator()
expect(res).assertEqual(2)
})
/**
* @tc.name: testRationalNumberIsFinite001
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsFinite001', 0, function () {
var pro = new util.RationalNumber(-2, 1)
var res = pro.isFinite()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsFinite002
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsFinite002', 0, function () {
var pro = new util.RationalNumber(0, 3)
var res = pro.isFinite()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsFinite003
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsFinite003', 0, function () {
var pro = new util.RationalNumber(2, 0)
var res = pro.isFinite()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsFinite004
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsFinite004', 0, function () {
var pro = new util.RationalNumber(1, 3)
var res = pro.isFinite()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsFinite005
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsFinite005', 0, function () {
var pro = new util.RationalNumber(10, 5)
var res = pro.isFinite()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsNaN001
* @tc.desc: Checks whether the current RationalNumber object represents a finite value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsNaN001', 0, function () {
var pro = new util.RationalNumber(-2, 1)
var res = pro.isNaN()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsNaN002
* @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsNaN002', 0, function () {
var pro = new util.RationalNumber(0, 3)
var res = pro.isNaN()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsNaN003
* @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsNaN003', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.isNaN()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsNaN004
* @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsNaN004', 0, function () {
var pro = new util.RationalNumber(10, 0)
var res = pro.isNaN()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsNaN005
* @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsNaN005', 0, function () {
var pro = new util.RationalNumber(10, 1)
var res = pro.isNaN()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsZero001
* @tc.desc: Checks whether the current RationalNumber object represents the value 0.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsZero001', 0, function () {
var pro = new util.RationalNumber(-2, 1)
var res = pro.isZero()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsZero002
* @tc.desc: Checks whether the current RationalNumber object represents the value 0.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsZero002', 0, function () {
var pro = new util.RationalNumber(0, 3)
var res = pro.isZero()
expect(res).assertEqual(true)
})
/**
* @tc.name: testRationalNumberIsZero003
* @tc.desc: Checks whether the current RationalNumber object represents the value 0.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsZero003', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.isZero()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsZero004
* @tc.desc: Checks whether the current RationalNumber object represents the value 0.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsZero004', 0, function () {
var pro = new util.RationalNumber(10, 2)
var res = pro.isZero()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberIsZero005
* @tc.desc: Checks whether the current RationalNumber object represents the value 0.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberIsZero005', 0, function () {
var pro = new util.RationalNumber(1, 1)
var res = pro.isZero()
expect(res).assertEqual(false)
})
/**
* @tc.name: testRationalNumberToString001
* @tc.desc: Obtains a string representation of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberToString001', 0, function () {
var pro = new util.RationalNumber(-2, 1)
var res = pro.toString()
expect(res).assertEqual("-2/1")
})
/**
* @tc.name: testRationalNumberToString002
* @tc.desc: Obtains a string representation of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberToString002', 0, function () {
var pro = new util.RationalNumber(0, 0)
var res = pro.toString()
expect(res).assertEqual("NaN")
})
/**
* @tc.name: testRationalNumberToString003
* @tc.desc: Obtains a string representation of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberToString003', 0, function () {
var pro = new util.RationalNumber(3, 0)
var res = pro.toString()
expect(res).assertEqual("Infinity")
})
/**
* @tc.name: testRationalNumberToString004
* @tc.desc: Obtains a string representation of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberToString004', 0, function () {
var pro = new util.RationalNumber(-3, 0)
var res = pro.toString()
expect(res).assertEqual("-Infinity")
})
/**
* @tc.name: testRationalNumberToString005
* @tc.desc: Obtains a string representation of the current RationalNumber object.
* @tc.require: AR000GFB5A
* @tc.author: liuqiang
*/
it('testRationalNumberToString005', 0, function () {
var pro = new util.RationalNumber(2, 3)
var res = pro.toString()
expect(res).assertEqual('2/3')
})
})
describe('LruBufferFunTest', function () {
/**
* @tc.name: testLruBufferUpdateCapacity001
* @tc.desc: Updates the buffer capacity to a specified capacity.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferUpdateCapacity001', 0, function () {
var that = new util.LruBuffer()
that.updateCapacity(10)
var result = that.capacity()
expect(result).assertEqual(10)
})
/**
* @tc.name: testLruBufferUpdateCapacity002
* @tc.desc: Updates the buffer capacity to a specified capacity.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferUpdateCapacity002', 0, function () {
var that = new util.LruBuffer()
that.updateCapacity(80)
var result = that.capacity()
expect(result).assertEqual(80)
})
/**
* @tc.name: testLruBufferUpdateCapacity003
* @tc.desc: Updates the buffer capacity to a specified capacity.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferUpdateCapacity003', 0, function () {
var that = new util.LruBuffer(100)
that.updateCapacity(20)
var result = that.capacity()
expect(result).assertEqual(20)
})
/**
* @tc.name: testLruBufferUpdateCapacity004
* @tc.desc: Updates the buffer capacity to a specified capacity.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferUpdateCapacity004', 0, function () {
var that = new util.LruBuffer(50)
that.updateCapacity(2)
var result = that.capacity()
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferUpdateCapacity005
* @tc.desc: Updates the buffer capacity to a specified capacity.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferUpdateCapacity005', 0, function () {
var that = new util.LruBuffer(200)
that.updateCapacity(100)
var result = that.capacity()
expect(result).assertEqual(100)
})
/**
* @tc.name: testLruBufferGet001
* @tc.desc: Obtains the value associated with a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGet001', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
var result = that.get(1)
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferGet002
* @tc.desc: Obtains the value associated with a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGet002', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
var result = that.get(5)
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferGet003
* @tc.desc: Obtains the value associated with a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGet003', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
var result1 = that.get(20)
var result2 = that.get('abcd')
var result3 = that.get(2)
expect(result1).assertEqual(undefined)
expect(result2).assertEqual(15)
expect(result3).assertEqual(10)
})
/**
* @tc.name: testLruBufferGet004
* @tc.desc: Obtains the value associated with a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGet004', 0, function () {
var that = new util.LruBuffer()
that.put('1111','bcjdshc')
that.put(20,'cdjcaxb')
that.put('abcd',15)
var result1 = that.get('1111')
var result2 = that.get(20)
var result3 = that.get('abcd')
var result4 = that.get(25)
expect(result1).assertEqual('bcjdshc')
expect(result2).assertEqual('cdjcaxb')
expect(result3).assertEqual(15)
expect(result4).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferGet005
* @tc.desc: Obtains the value associated with a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGet005', 0, function () {
var that = new util.LruBuffer()
that.put('1111','bcjdshc')
that.put(20,'cdjcaxb')
that.updateCapacity(2)
that.put('abcd',15)
var result1 = that.get('1111')
var result2 = that.get(20)
var result3 = that.get('abcd')
var result4 = that.get(25)
expect(result1).assertEqual(undefined)
expect(result2).assertEqual('cdjcaxb')
expect(result3).assertEqual(15)
expect(result4).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferPut001
* @tc.desc: Adds a key-value pair to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferPut001', 0, function () {
var that = new util.LruBuffer()
var temp = that.put('1111','bcjdshc')
expect(temp).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferPut002
* @tc.desc: Adds a key-value pair to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferPut002', 0, function () {
var that = new util.LruBuffer()
var temp1 = that.put('1111','bcjdshc')
var temp2 = that.put('1111',13)
expect(temp2).assertEqual('bcjdshc')
})
/**
* @tc.name: testLruBufferPut003
* @tc.desc: Adds a key-value pair to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferPut003', 0, function () {
var that = new util.LruBuffer()
var temp = that.put('1111','bcjdshc')
var temp1 = that.put(1,12)
var temp2 = that.put(2,5)
var temp3 = that.put(2,'adasfdad')
var temp4 = that.put('abc',10)
expect(temp1).assertEqual(undefined)
expect(temp2).assertEqual(undefined)
expect(temp3).assertEqual(5)
expect(temp4).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferPut004
* @tc.desc: Adds a key-value pair to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferPut004', 0, function () {
var that = new util.LruBuffer()
var temp = that.put('1111','bcjdshc')
var temp1 = that.put(1,12)
var temp2 = that.put(2,5)
that.updateCapacity(2)
var temp3 = that.put(2,'adasfdad')
var temp4 = that.put('1111',10)
expect(temp).assertEqual(undefined)
expect(temp1).assertEqual(undefined)
expect(temp2).assertEqual(undefined)
expect(temp3).assertEqual(5)
expect(temp4).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferPut005
* @tc.desc: Adds a key-value pair to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferPut005', 0, function () {
var that = new util.LruBuffer()
var temp = that.put('1111','bcjdshc')
var temp1 = that.put(1,12)
var temp2 = that.put(2,5)
var temp3 = that.put(1,10)
var temp4 = that.put(2,22)
var temp5 = that.put(2,30)
expect(temp).assertEqual(undefined)
expect(temp1).assertEqual(undefined)
expect(temp2).assertEqual(undefined)
expect(temp3).assertEqual(12)
expect(temp4).assertEqual(5)
expect(temp5).assertEqual(22)
})
/**
* @tc.name: testLruBufferGetCreateCount001
* @tc.desc: Obtains the number of times createDefault(Object) returned a value.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetCreateCount001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(3)
that.get(5)
that.get(10)
var result = that.getCreateCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetCreateCount002
* @tc.desc: Obtains the number of times createDefault(Object) returned a value.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetCreateCount002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(6)
that.get(8)
that.get(20)
var result = that.getCreateCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetCreateCount003
* @tc.desc: Obtains the number of times createDefault(Object) returned a value.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetCreateCount003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.get('abc')
that.get('cndk')
var result = that.getCreateCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetCreateCount004
* @tc.desc: Obtains the number of times createDefault(Object) returned a value.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetCreateCount004', 0, function () {
var that = new util.LruBuffer()
that.put(5,2)
that.put(10,10)
that.put('abcd','abcd')
that.get(3)
that.get(20)
that.get(12)
var result = that.getCreateCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetCreateCount005
* @tc.desc: Obtains the number of times createDefault(Object) returned a value.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetCreateCount005', 0, function () {
var that = new util.LruBuffer()
that.put('xsjk','bcjds')
that.put('ajc',10)
that.put('abcd',15)
that.get(2)
that.get(10)
that.get(30)
var result = that.getCreateCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetMissCount001
* @tc.desc: Obtains the number of times that the queried values are not matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMissCount001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(3)
that.get(5)
that.get(10)
var result = that.getMissCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMissCount002
* @tc.desc: Obtains the number of times that the queried values are not matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMissCount002', 0, function () {
var that = new util.LruBuffer()
that.put(5,2)
that.put(1,10)
that.put('abcd','bcjsc')
that.get(2)
that.get(10)
that.get(15)
var result = that.getMissCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMissCount003
* @tc.desc: Obtains the number of times that the queried values are not matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMissCount003', 0, function () {
var that = new util.LruBuffer()
that.put(10,10)
that.put(3,20)
that.put(12,16)
that.get(1)
that.get(2)
that.get(6)
var result = that.getMissCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMissCount004
* @tc.desc: Obtains the number of times that the queried values are not matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMissCount004', 0, function () {
var that = new util.LruBuffer()
that.put('acb','asdc')
that.put('vfb',1)
that.put('abcd','abcd')
that.get(3)
that.get(5)
that.get(10)
var result = that.getMissCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMissCount005
* @tc.desc: Obtains the number of times that the queried values are not matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMissCount005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(3)
that.get(5)
that.get(10)
that.contains(2)
that.contains(6)
var result = that.getMissCount()
expect(result).assertEqual(4)
})
/**
* @tc.name: testLruBufferGetRemovalCount001
* @tc.desc: Obtains the number of times that values are evicted from the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetRemovalCount001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.put(3,20)
that.put(5,30)
var result = that.getRemovalCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetRemovalCount002
* @tc.desc: Obtains the number of times that values are evicted from the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetRemovalCount002', 0, function () {
var that = new util.LruBuffer()
that.put(10,2)
that.put(3,2)
that.put(15,15)
that.put(1,20)
var result = that.getRemovalCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetRemovalCount003
* @tc.desc: Obtains the number of times that values are evicted from the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetRemovalCount003', 0, function () {
var that = new util.LruBuffer()
that.put('abc',2)
that.put('abcd','abcd')
that.put(3,2)
var result = that.getRemovalCount()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferGetRemovalCount004
* @tc.desc: Obtains the number of times that values are evicted from the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetRemovalCount004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.updateCapacity(2)
that.put(3,20)
that.put(5,30)
var result = that.getRemovalCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetRemovalCount005
* @tc.desc: Obtains the number of times that values are evicted from the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetRemovalCount005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.updateCapacity(3)
that.put('string',20)
that.put('abc',30)
that.put(10,20)
var result = that.getRemovalCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMatchCount001
* @tc.desc: Obtains the number of times that the queried values are successfully matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMatchCount001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(1)
that.get(2)
that.get('abcd')
var result = that.getMatchCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMatchCount002
* @tc.desc: Obtains the number of times that the queried values are successfully matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMatchCount002', 0, function () {
var that = new util.LruBuffer()
that.put(10,2)
that.put(2,1)
that.put('abcd',15)
that.get(10)
that.get(2)
that.get('abcd')
that.get('string')
var result = that.getMatchCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMatchCount003
* @tc.desc: Obtains the number of times that the queried values are successfully matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMatchCount003', 0, function () {
var that = new util.LruBuffer()
that.put(0,1)
that.put(30,10)
that.put('abcd',15)
that.get(0)
that.get(30)
that.get('abcd')
var result = that.getMatchCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetMatchCount004
* @tc.desc: Obtains the number of times that the queried values are successfully matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMatchCount004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.get(1)
that.get(2)
that.get('abcd')
that.contains(2)
that.contains('abcd')
that.contains(20)
var result = that.getMatchCount()
expect(result).assertEqual(5)
})
/**
* @tc.name: testLruBufferGetMatchCount005
* @tc.desc: Obtains the number of times that the queried values are successfully matched.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetMatchCount005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.put('string','string')
that.get(1)
that.get(2)
that.get('abcd')
that.get('string')
that.contains(2)
that.contains('abcd')
that.contains('string')
that.contains(10)
var result = that.getMatchCount()
expect(result).assertEqual(7)
})
/**
* @tc.name: testLruBufferGetPutCount001
* @tc.desc: Obtains the number of times that values are added to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetPutCount001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result = that.getPutCount()
expect(result).assertEqual(1)
})
/**
* @tc.name: testLruBufferGetPutCount002
* @tc.desc: Obtains the number of times that values are added to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetPutCount002', 0, function () {
var that = new util.LruBuffer()
that.put(5,3)
that.put(2,10)
var result = that.getPutCount()
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferGetPutCount003
* @tc.desc: Obtains the number of times that values are added to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetPutCount003', 0, function () {
var that = new util.LruBuffer()
that.put('string',2)
that.put('abcd',1)
that.put('ab','a')
var result = that.getPutCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetPutCount004
* @tc.desc: Obtains the number of times that values are added to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetPutCount004', 0, function () {
var that = new util.LruBuffer()
that.put('string','string')
that.put('ac','abc')
that.put('abcd',15)
var result = that.getPutCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferGetPutCount005
* @tc.desc: Obtains the number of times that values are added to the buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferGetPutCount005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.updateCapacity(2)
that.put('abcd','abc')
var result = that.getPutCount()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferCapacity001
* @tc.desc: Obtains the capacity of the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCapacity001', 0, function () {
var that = new util.LruBuffer()
var result = that.capacity()
expect(result).assertEqual(64)
})
/**
* @tc.name: testLruBufferCapacity002
* @tc.desc: Obtains the capacity of the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCapacity002', 0, function () {
var that = new util.LruBuffer(2)
var result = that.capacity()
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferCapacity003
* @tc.desc: Obtains the capacity of the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCapacity003', 0, function () {
var that = new util.LruBuffer(100)
var result = that.capacity()
expect(result).assertEqual(100)
})
/**
* @tc.name: testLruBufferCapacity004
* @tc.desc: Obtains the capacity of the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCapacity004', 0, function () {
var that = new util.LruBuffer()
that.updateCapacity(50)
var result = that.capacity()
expect(result).assertEqual(50)
})
/**
* @tc.name: testLruBufferCapacity005
* @tc.desc: Obtains the capacity of the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCapacity005', 0, function () {
var that = new util.LruBuffer(100)
that.updateCapacity(10)
var result = that.capacity()
expect(result).assertEqual(10)
})
/**
* @tc.name: testLruBufferSize001
* @tc.desc: Obtains the total number of values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferSize001', 0, function () {
var that = new util.LruBuffer()
var result = that.size()
expect(result).assertEqual(0)
})
/**
* @tc.name: testLruBufferSize002
* @tc.desc: Obtains the total number of values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferSize002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result = that.size()
expect(result).assertEqual(1)
})
/**
* @tc.name: testLruBufferSize003
* @tc.desc: Obtains the total number of values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferSize003', 0, function () {
var that = new util.LruBuffer()
that.put('abc',2)
that.put('string','string')
var result = that.size()
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferSize004
* @tc.desc: Obtains the total number of values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferSize004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.put('abcd',20)
var result = that.size()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferSize005
* @tc.desc: Obtains the total number of values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferSize005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put('abcd',15)
that.put('abcd',20)
that.updateCapacity(3);
that.put(5,33);
that.put(25,35);
var result = that.size()
expect(result).assertEqual(3)
})
/**
* @tc.name: testLruBufferClear001
* @tc.desc: Clears key-value pairs from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferClear001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result1 = that.size()
that.clear()
var result2 = that.size()
expect(result1).assertEqual(1)
expect(result2).assertEqual(0)
})
/**
* @tc.name: testLruBufferClear002
* @tc.desc: Clears key-value pairs from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferClear002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put(5,33);
that.put(25,35);
var result1 = that.size()
that.clear()
var result2 = that.size()
expect(result1).assertEqual(4)
expect(result2).assertEqual(0)
})
/**
* @tc.name: testLruBufferClear003
* @tc.desc: Clears key-value pairs from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferClear003', 0, function () {
var that = new util.LruBuffer()
that.put('abc',2)
that.put(2,'abc')
that.put('ancd','abcd')
that.put(10,35)
var result1 = that.size()
that.clear()
var result2 = that.size()
expect(result1).assertEqual(4)
expect(result2).assertEqual(0)
})
/**
* @tc.name: testLruBufferClear004
* @tc.desc: Clears key-value pairs from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferClear004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put(5,33);
that.updateCapacity(3);
var result1 = that.size()
that.clear()
var result2 = that.size()
expect(result1).assertEqual(3)
expect(result2).assertEqual(0)
})
/**
* @tc.name: testLruBufferClear005
* @tc.desc: Clears key-value pairs from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferClear005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put(5,33);
that.put('abcd','string');
that.updateCapacity(2);
var result1 = that.size()
that.clear()
var result2 = that.size()
expect(result1).assertEqual(2)
expect(result2).assertEqual(0)
})
/**
* @tc.name: testLruBufferIsEmpty001
* @tc.desc: Checks whether the current buffer is empty.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferIsEmpty001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result = that.isEmpty()
expect(result).assertEqual(false)
})
/**
* @tc.name: testLruBufferIsEmpty002
* @tc.desc: Checks whether the current buffer is empty.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferIsEmpty002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
var result = that.isEmpty()
expect(result).assertEqual(false)
})
/**
* @tc.name: testLruBufferIsEmpty003
* @tc.desc: Checks whether the current buffer is empty.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferIsEmpty003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put(5,33)
var result = that.isEmpty()
expect(result).assertEqual(false)
})
/**
* @tc.name: testLruBufferIsEmpty004
* @tc.desc: Checks whether the current buffer is empty.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferIsEmpty004', 0, function () {
var that = new util.LruBuffer()
that.put('abc',2)
that.put('string',10)
that.put('ab','abc')
var result = that.isEmpty()
expect(result).assertEqual(false)
})
/**
* @tc.name: testLruBufferIsEmpty005
* @tc.desc: Checks whether the current buffer is empty.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferIsEmpty005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(2,10)
that.put(5,33);
that.clear()
var result = that.isEmpty()
expect(result).assertEqual(true)
})
/**
* @tc.name: testLruBufferContains001
* @tc.desc: Checks whether the current buffer contains a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferContains001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result = that.contains(1)
expect(result).assertEqual(true)
})
/**
* @tc.name: testLruBufferContains002
* @tc.desc: Checks whether the current buffer contains a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferContains002', 0, function () {
var that = new util.LruBuffer()
that.put(0,5)
var result = that.contains(0)
expect(result).assertEqual(true)
})
/**
* @tc.name: testLruBufferContains003
* @tc.desc: Checks whether the current buffer contains a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferContains003', 0, function () {
var that = new util.LruBuffer()
that.put('abc','abc')
var result = that.contains(1)
expect(result).assertEqual(false)
})
/**
* @tc.name: testLruBufferContains004
* @tc.desc: Checks whether the current buffer contains a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferContains004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put('abcd',20)
var result1 = that.contains(1)
var result2 = that.contains(20)
expect(result1).assertEqual(true)
expect(result2).assertEqual(false)
})
/**
* @tc.name: testLruBufferContains005
* @tc.desc: Checks whether the current buffer contains a specified key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferContains005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put('string','string')
var result1 = that.contains(1)
var result2 = that.contains('string')
var result3 = that.contains(0)
expect(result1).assertEqual(true)
expect(result2).assertEqual(true)
expect(result3).assertEqual(false)
})
/**
* @tc.name: testLruBufferRemove001
* @tc.desc: Deletes a specified key and its associated value from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferRemove001', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result = that.remove(1)
expect(result).assertEqual(2)
})
/**
* @tc.name: testLruBufferRemove002
* @tc.desc: Deletes a specified key and its associated value from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferRemove002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put('abcd',20)
var result1 = that.remove(1)
var result2 = that.remove('abcd')
expect(result1).assertEqual(2)
expect(result2).assertEqual(20)
})
/**
* @tc.name: testLruBufferRemove003
* @tc.desc: Deletes a specified key and its associated value from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferRemove003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
var result1 = that.remove(1)
var result2 = that.remove(5)
expect(result1).assertEqual(2)
expect(result2).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferRemove004
* @tc.desc: Deletes a specified key and its associated value from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferRemove004', 0, function () {
var that = new util.LruBuffer()
that.put(0,'abc')
that.put('abcd',20)
var result1 = that.remove(1)
var result2 = that.remove('abcd')
expect(result1).assertEqual(undefined)
expect(result2).assertEqual(20)
})
/**
* @tc.name: testLruBufferRemove005
* @tc.desc: Deletes a specified key and its associated value from the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferRemove005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
var result1 = that.remove(1)
var result2 = that.remove(3)
var result3 = that.get(3)
expect(result1).assertEqual(2)
expect(result2).assertEqual(10)
expect(result3).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferCreateDefault001
* @tc.desc: Executes subsequent operations if miss to compute a value for the specific key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCreateDefault001', 0, function () {
var that = new util.LruBuffer()
var result = that.createDefault(1)
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferCreateDefault002
* @tc.desc: Executes subsequent operations if miss to compute a value for the specific key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCreateDefault002', 0, function () {
var that = new util.LruBuffer()
var result = that.createDefault(0)
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferCreateDefault003
* @tc.desc: Executes subsequent operations if miss to compute a value for the specific key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCreateDefault003', 0, function () {
var that = new util.LruBuffer()
var result = that.createDefault('string')
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferCreateDefault004
* @tc.desc: Executes subsequent operations if miss to compute a value for the specific key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCreateDefault004', 0, function () {
var that = new util.LruBuffer()
var result = that.createDefault(10)
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferCreateDefault005
* @tc.desc: Executes subsequent operations if miss to compute a value for the specific key.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferCreateDefault005', 0, function () {
var that = new util.LruBuffer()
var result1 = that.createDefault('abc')
var result2 = that.createDefault('ab')
expect(result1).assertEqual(undefined)
expect(result2).assertEqual(undefined)
})
/**
* @tc.name: testLruBufferKeys001
* @tc.desc: Obtains a list of keys for the values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferKeys001', 0, function () {
var that = new util.LruBuffer()
that.put('string','abc')
var result = that.keys()
expect(result[0]).assertEqual('string')
})
/**
* @tc.name: testLruBufferKeys002
* @tc.desc: Obtains a list of keys for the values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferKeys002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
var result = that.keys()
expect(result[0]).assertEqual(1)
expect(result[1]).assertEqual(3)
expect(result[2]).assertEqual(5)
expect(result[3]).assertEqual('abc')
})
/**
* @tc.name: testLruBufferKeys003
* @tc.desc: Obtains a list of keys for the values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferKeys003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
var result = that.keys()
expect(result[0]).assertEqual(1)
expect(result[1]).assertEqual(5)
expect(result[2]).assertEqual('abc')
expect(result[3]).assertEqual(3)
})
/**
* @tc.name: testLruBufferKeys004
* @tc.desc: Obtains a list of keys for the values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferKeys004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.contains(1)
var result = that.keys()
expect(result[0]).assertEqual(5)
expect(result[1]).assertEqual('abc')
expect(result[2]).assertEqual(3)
expect(result[3]).assertEqual(1)
})
/**
* @tc.name: testLruBufferKeys005
* @tc.desc: Obtains a list of keys for the values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferKeys005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.remove(5)
that.contains(3)
that.get(1)
that.contains('abc')
var result = that.keys()
expect(result[0]).assertEqual(3)
expect(result[1]).assertEqual(1)
expect(result[2]).assertEqual('abc')
})
/**
* @tc.name: testLruBufferValues001
* @tc.desc: Obtains a list of all values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferValues001', 0, function () {
var that = new util.LruBuffer()
that.put('string','abc')
var result = that.values()
expect(result[0]).assertEqual('abc')
})
/**
* @tc.name: testLruBufferValues002
* @tc.desc: Obtains a list of all values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferValues002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
var result = that.values()
expect(result[0]).assertEqual(2)
expect(result[1]).assertEqual(10)
expect(result[2]).assertEqual(15)
expect(result[3]).assertEqual(20)
})
/**
* @tc.name: testLruBufferValues003
* @tc.desc: Obtains a list of all values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferValues003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
var result = that.values()
expect(result[0]).assertEqual(2)
expect(result[1]).assertEqual(15)
expect(result[2]).assertEqual(20)
expect(result[3]).assertEqual(10)
})
/**
* @tc.name: testLruBufferValues004
* @tc.desc: Obtains a list of all values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferValues004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.contains(1)
var result = that.values()
expect(result[0]).assertEqual(15)
expect(result[1]).assertEqual(20)
expect(result[2]).assertEqual(10)
expect(result[3]).assertEqual(2)
})
/**
* @tc.name: testLruBufferValues005
* @tc.desc: Obtains a list of all values in the current buffer.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferValues005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.remove(5)
that.contains(3)
that.get(1)
that.contains('abc')
var result = that.values()
expect(result[0]).assertEqual(10)
expect(result[1]).assertEqual(2)
expect(result[2]).assertEqual(20)
})
/**
* @tc.name: testLruBufferToString001
* @tc.desc: Returns a string representation of the object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferToString001', 0, function () {
var that = new util.LruBuffer()
that.put('1111','bcjdshc')
that.put(1,2)
var result = that.toString()
expect(result).assertEqual('Lrubuffer[ maxSize = 64, hits = 0, misses = 0, hitRate = 0% ]')
})
/**
* @tc.name: testLruBufferToString002
* @tc.desc: Returns a string representation of the object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferToString002', 0, function () {
var that = new util.LruBuffer()
that.put('1111','bcjdshc')
that.put(1,2)
that.get(1)
that.get('1111')
var result = that.toString()
expect(result).assertEqual('Lrubuffer[ maxSize = 64, hits = 2, misses = 0, hitRate = 100% ]')
})
/**
* @tc.name: testLruBufferToString003
* @tc.desc: Returns a string representation of the object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferToString003', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
var result = that.toString()
expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 1, misses = 0, hitRate = 100% ]')
})
/**
* @tc.name: testLruBufferToString004
* @tc.desc: Returns a string representation of the object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferToString004', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.get(2)
var result = that.toString()
expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 1, misses = 1, hitRate = 50% ]')
})
/**
* @tc.name: testLruBufferToString005
* @tc.desc: Returns a string representation of the object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferToString005', 0, function () {
var that = new util.LruBuffer(100)
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.get(2)
that.get(1)
that.contains(5)
var result = that.toString()
expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 3, misses = 1, hitRate = 75% ]')
})
/**
* @tc.name: testLruBufferEntries001
* @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferEntries001', 0, function () {
var that = new util.LruBuffer()
that.put('string','abc')
var i=0;
var arr={};
for (let entry of that.entries()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual('abc');
})
/**
* @tc.name: testLruBufferEntries002
* @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferEntries002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
var i=0;
var arr={};
for (let entry of that.entries()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(2);
})
/**
* @tc.name: testLruBufferEntries003
* @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferEntries003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
var i=0;
var arr={};
for (let entry of that.entries()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[0]).assertEqual(1);
})
/**
* @tc.name: testLruBufferEntries004
* @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferEntries004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.contains(1)
var i=0;
var arr={};
for (let entry of that.entries()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(15)
expect(arr[3]).assertEqual(20)
})
/**
* @tc.name: testLruBufferEntries005
* @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferEntries005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.remove(5)
that.contains(3)
that.get(1)
that.contains('abc')
var i=0;
var arr={};
for (let entry of that.entries()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(10)
expect(arr[3]).assertEqual(2)
expect(arr[5]).assertEqual(20)
})
/**
* @tc.name: testLruBuffer[Symbol.iterator]001
* @tc.desc: Returns a two - dimensional array in the form of key - value pairs.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBuffer[Symbol.iterator]001', 0, function () {
var that = new util.LruBuffer()
that.put('string','abc')
that.put('abc',20)
var i=0;
var arr={};
for (let entry of that[Symbol.iterator]()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual('abc');
})
/**
* @tc.name: testLruBuffer[Symbol.iterator]002
* @tc.desc: Returns a two - dimensional array in the form of key - value pairs.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBuffer[Symbol.iterator]002', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
var i=0;
var arr={};
for (let entry of that[Symbol.iterator]()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(2);
})
/**
* @tc.name: testLruBuffer[Symbol.iterator]003
* @tc.desc: Returns a two - dimensional array in the form of key - value pairs.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBuffer[Symbol.iterator]003', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
var i=0;
var arr={};
for (let entry of that[Symbol.iterator]()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[0]).assertEqual(1);
})
/**
* @tc.name: testLruBuffer[Symbol.iterator]004
* @tc.desc: Returns a two - dimensional array in the form of key - value pairs.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBuffer[Symbol.iterator]004', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.contains(1)
var i=0;
var arr={};
for (let entry of that[Symbol.iterator]()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(15)
expect(arr[3]).assertEqual(20)
})
/**
* @tc.name: testLruBuffer[Symbol.iterator]005
* @tc.desc: Returns a two - dimensional array in the form of key - value pairs.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBuffer[Symbol.iterator]005', 0, function () {
var that = new util.LruBuffer()
that.put(1,2)
that.put(3,10)
that.put(5,15)
that.put('abc',20)
that.get(3)
that.remove(5)
that.contains(3)
that.get(1)
that.contains('abc')
var i=0;
var arr={};
for (let entry of that[Symbol.iterator]()) {
arr[i]=entry[0];
i++;
arr[i]=entry[1];
i++;
};
expect(arr[1]).assertEqual(10)
expect(arr[3]).assertEqual(2)
expect(arr[5]).assertEqual(20)
})
/**
* @tc.name: testLruBufferAfterRemoval001
* @tc.desc: Executes subsequent operations after a value is deleted.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferAfterRemoval001', 0, function () {
var arr = [];
class ChildLruBuffer extends util.LruBuffer
{
constructor()
{
super();
}
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
ChildLruBuffer.getInstance().afterRemoval(false,10,30,null)
expect(arr[0]).assertEqual(10)
})
/**
* @tc.name: testLruBufferAfterRemoval002
* @tc.desc: Executes subsequent operations after a value is deleted.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferAfterRemoval002', 0, function () {
var arr = [];
class ChildLruBuffer extends util.LruBuffer
{
constructor()
{
super();
}
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
ChildLruBuffer.getInstance().afterRemoval(false,'string',10,null)
expect(arr[0]).assertEqual('string')
})
/**
* @tc.name: testLruBufferAfterRemoval003
* @tc.desc: Executes subsequent operations after a value is deleted.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferAfterRemoval003', 0, function () {
var arr = [];
class ChildLruBuffer extends util.LruBuffer
{
constructor()
{
super();
}
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
ChildLruBuffer.getInstance().afterRemoval(false,10,30,12)
expect(arr[2]).assertEqual(12)
})
/**
* @tc.name: testLruBufferAfterRemoval004
* @tc.desc: Executes subsequent operations after a value is deleted.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferAfterRemoval004', 0, function () {
var arr = [];
class ChildLruBuffer extends util.LruBuffer
{
constructor()
{
super();
}
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === false)
{
arr = [key, value, newValue];
}
}
}
ChildLruBuffer.getInstance().afterRemoval(false,'abc',30,'string')
expect(arr[1]).assertEqual(30)
})
/**
* @tc.name: testLruBufferAfterRemoval005
* @tc.desc: Executes subsequent operations after a value is deleted.
* @tc.require: AR000GFB59
* @tc.author: lixingyang
*/
it('testLruBufferAfterRemoval005', 0, function () {
var arr = [];
class ChildLruBuffer extends util.LruBuffer
{
constructor()
{
super();
}
static getInstance()
{
if(this.instance == null)
{
this.instance = new ChildLruBuffer();
}
return this.instance;
}
afterRemoval(isEvict, key, value, newValue)
{
if (isEvict === true)
{
arr = [key, value, newValue];
}
}
}
ChildLruBuffer.getInstance().afterRemoval(true,'abc','ab','string')
expect(arr[2]).assertEqual('string')
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册