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

!7616 Modified the static functions of rationalnumber【monthly_20221018】

Merge pull request !7616 from jwx1068251/monthly_20221018
......@@ -3407,7 +3407,7 @@ describe('FunctionTest', function () {
})
/**
* @tc.name: testUtilformat001
* @tc.name: testUtilformatThrowError001
* @tc.desc: Returns the formatted string.
*/
it('testUtilformatThrowError001', 0, function () {
......@@ -3551,11 +3551,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_parseRationalNumber_001', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1, 2)
var res = pro.createRationalFromString('+2:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
var res = util.RationalNumber.parseRationalNumber(2, 1)
var result = res.valueOf()
expect(result).assertEqual(2)
})
/**
......@@ -3564,11 +3562,9 @@ describe('RationalNumberTest', function () {
*/
it('test_parseRationalNumberThrowError_001', 0, function () {
try {
var pro = new util.RationalNumber()
pro.parseRationalNumber('str', 2)
var res = pro.createRationalFromString('+2:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
var pro = util.RationalNumber.parseRationalNumber('str', 2)
var result = res.valueOf()
expect(result).assertEqual(2)
} catch (e) {
expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of str must be number");
}
......@@ -3579,11 +3575,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_001', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1,2)
var res = pro.createRationalFromString('-1:2')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
var res = util.RationalNumber.createRationalFromString('-1:2')
var result = res.valueOf()
expect(result).assertEqual(-0.5)
})
/**
......@@ -3591,11 +3585,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_002', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1,2)
var res = pro.createRationalFromString('+3/4')
var result1 = res.valueOf()
expect(result1).assertEqual(0.75)
var res = util.RationalNumber.createRationalFromString('+3/4')
var result = res.valueOf()
expect(result).assertEqual(0.75)
})
/**
......@@ -3603,11 +3595,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_003', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1,2)
var res = pro.createRationalFromString('+3:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.75)
var res = util.RationalNumber.createRationalFromString('+3:-4')
var result = res.valueOf()
expect(result).assertEqual(-0.75)
})
/**
......@@ -3615,11 +3605,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_004', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1,2)
var res = pro.createRationalFromString('+2:4')
var result1 = res.valueOf()
expect(result1).assertEqual(0.5)
var res = util.RationalNumber.createRationalFromString('+2:4')
var result = res.valueOf()
expect(result).assertEqual(0.5)
})
/**
......@@ -3627,11 +3615,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_005', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1,2)
var res = pro.createRationalFromString('+2:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
var res = util.RationalNumber.createRationalFromString('+2:-4')
var result = res.valueOf()
expect(result).assertEqual(-0.5)
})
/**
......@@ -3640,11 +3626,9 @@ describe('RationalNumberTest', function () {
*/
it('test_createRationalFromStringThrowError_001', 0, function () {
try {
var pro = new util.RationalNumber()
pro.parseRationalNumber(1, 2)
var res = pro.createRationalFromString(123)
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
var res = util.RationalNumber.createRationalFromString(123)
var result = res.valueOf()
expect(result).assertEqual(-0.5)
} catch (e) {
expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of 123 must be string");
}
......@@ -3655,10 +3639,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it('test_compare_001', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(2, 1)
var proc = new util.RationalNumber()
proc.parseRationalNumber(3, 4)
var pro = util.RationalNumber.parseRationalNumber(2, 1)
var proc = util.RationalNumber.parseRationalNumber(3, 4)
var res = pro.compare(proc)
expect(res).assertEqual(1)
})
......@@ -3668,10 +3650,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it('test_compare_002', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(2, 1)
var proc = new util.RationalNumber()
proc.parseRationalNumber(0, 0)
var pro = util.RationalNumber.parseRationalNumber(2, 1)
var proc = util.RationalNumber.parseRationalNumber(0, 0)
var res = pro.compare(proc)
expect(res).assertEqual(-1)
})
......@@ -3681,10 +3661,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it('test_compare_003', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(2, 1)
var proc = new util.RationalNumber()
proc.parseRationalNumber(8, 3)
var pro = util.RationalNumber.parseRationalNumber(2, 1)
var proc = util.RationalNumber.parseRationalNumber(8, 3)
var res = pro.compare(proc)
expect(res).assertEqual(-1)
})
......@@ -3694,10 +3672,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it('test_compare_004', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(2, 1)
var proc = new util.RationalNumber()
proc.parseRationalNumber(2, 1)
var pro = util.RationalNumber.parseRationalNumber(2, 1)
var proc = util.RationalNumber.parseRationalNumber(2, 1)
var res = pro.compare(proc)
expect(res).assertEqual(0)
})
......@@ -3707,10 +3683,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it('test_compare_005', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var proc = new util.RationalNumber()
proc.parseRationalNumber(2, 1)
var pro = util.RationalNumber.parseRationalNumber(0, 0)
var proc = util.RationalNumber.parseRationalNumber(2, 1)
var res = pro.compare(proc)
expect(res).assertEqual(1)
})
......@@ -3721,8 +3695,7 @@ describe('RationalNumberTest', function () {
*/
it('test_compareThrowError_001', 0, function () {
try {
var pro = new util.RationalNumber()
pro.parseRationalNumber(2, 1)
var pro = util.RationalNumber.parseRationalNumber(2, 1)
var proc = 'str'
var res = pro.compare(proc)
expect(res).assertEqual(1)
......@@ -3736,9 +3709,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it('testgetCommonFactor001', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor(4, 8)
var res = util.RationalNumber.getCommonFactor(4, 8)
expect(res).assertEqual(4)
})
......@@ -3747,9 +3718,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it('testgetCommonFactor002', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor(10, 15)
var res = util.RationalNumber.getCommonFactor(10, 15)
expect(res).assertEqual(5)
})
......@@ -3758,9 +3727,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it('testgetCommonFactor003', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor(8, 4)
var res = util.RationalNumber.getCommonFactor(8, 4)
expect(res).assertEqual(4)
})
......@@ -3769,9 +3736,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it('testgetCommonFactor004', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor(8, 16)
var res = util.RationalNumber.getCommonFactor(8, 16)
expect(res).assertEqual(8)
})
......@@ -3780,9 +3745,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it('testgetCommonFactor005', 0, function () {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor(2, 16)
var res = util.RationalNumber.getCommonFactor(2, 16)
expect(res).assertEqual(2)
})
......@@ -3792,9 +3755,7 @@ describe('RationalNumberTest', function () {
*/
it('testgetCommonFactorThrowError001', 0, function () {
try {
var pro = new util.RationalNumber()
pro.parseRationalNumber(0, 0)
var res = pro.getCommonFactor('str', 8)
var res = util.RationalNumber.getCommonFactor('str', 8)
expect(res).assertEqual(4)
} catch (e) {
expect(e.toString()).assertEqual("BusinessError: Parameter error.The type of str must be number");
......@@ -4202,11 +4163,11 @@ describe('Base64HelperTest', function () {
})
/**
* @tc.name: test_encodeSync_base64_005
* @tc.name: test_encodeSync_base64_throwError_001
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8
array using the Base64 encoding scheme.
*/
it('test_encodeSync_base64_005', 0, async function () {
it('test_encodeSync_base64_throwError_001', 0, async function () {
try {
var that = new util.Base64Helper()
var array = new Uint32Array([66, 97, 115, 101, 54, 52]);
......@@ -4455,11 +4416,11 @@ describe('Base64HelperTest', function () {
})
/**
* @tc.name: test_decode_base64_011
* @tc.name: test_decode_base64_throwError_001
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8
array into a newly allocated u8 array.
*/
it('test_decode_base64_006', 0, async function () {
it('test_decode_base64_throwError_001', 0, async function () {
try {
var that = new util.Base64Helper()
var array = new Uint16Array([99,122,69,122]);
......@@ -4550,10 +4511,10 @@ describe('DecodeEncodeTest', function () {
})
/**
* @tc.name: testencoding_textdecoder_ThrowError_002
* @tc.name: testencoding_textdecoder_ThrowError_003
* @tc.desc: The source encoding's name, lowercased.
*/
it('testencoding_textdecoder_ThrowError_002', 0, function () {
it('testencoding_textdecoder_ThrowError_003', 0, function () {
try {
var that = util.TextDecoder.create('utf-16be', 123)
var encodingStr = that.encoding
......@@ -4680,7 +4641,7 @@ describe('DecodeEncodeTest', function () {
* @tc.name: testEncodeInto010
* @tc.desc: Returns the result of encoder for GB18030.
*/
it('testEncodeInto0010', 0, function () {
it('testEncodeInto010', 0, function () {
let that = new util.TextEncoder('GB18030')
let buffer = new ArrayBuffer(20)
let result = new Uint8Array(buffer)
......
......@@ -2403,8 +2403,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_001', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('-1:2')
var res = util.RationalNumber.createRationalFromString('-1:2')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
})
......@@ -2414,8 +2413,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_002', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+3/4')
var res = util.RationalNumber.createRationalFromString('+3/4')
var result1 = res.valueOf()
expect(result1).assertEqual(0.75)
})
......@@ -2425,8 +2423,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_003', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+3:-4')
var res = util.RationalNumber.createRationalFromString('+3:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.75)
})
......@@ -2436,8 +2433,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_004', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+2:4')
var res = util.RationalNumber.createRationalFromString('+2:4')
var result1 = res.valueOf()
expect(result1).assertEqual(0.5)
})
......@@ -2447,10 +2443,9 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it('test_createRationalFromString_005', 0, function () {
var pro = new util.RationalNumber(1, 2)
var res = pro.createRationalFromString('+2:-4')
var res = util.RationalNumber.createRationalFromString('-2:-4')
var result1 = res.valueOf()
expect(result1).assertEqual(-0.5)
expect(result1).assertEqual(0.5)
})
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册