提交 d0fb46eb 编写于 作者: L lengchangjing

modify buffer interface exception

Signed-off-by: Nlengchangjing <lengchangjing@huawei.com>
上级 67becab0
......@@ -21,7 +21,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0010
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(10);
* @tc.author: liuganlin
*/
it("testAlloc0010", 0, function () {
let buf = buffer.alloc(10);
......@@ -32,7 +31,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0011
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(10).fill(string);
* @tc.author: liuganlin
*/
it("testAlloc0011", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -47,7 +45,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0012
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(10).fill(buffer);
* @tc.author: liuganlin
*/
it("testAlloc0012", 0, function () {
let buf1 = buffer.alloc(10);
......@@ -59,7 +56,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0013
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(0);
* @tc.author: liuganlin
*/
it("testAlloc0013", 0, function () {
let buf = buffer.alloc(0);
......@@ -70,7 +66,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0014
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(0).fill(string, encode);
* @tc.author: liuganlin
*/
it("testAlloc0014", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -85,7 +80,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0015
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(0).fill(buffer);
* @tc.author: liuganlin
*/
it("testAlloc0015", 0, function () {
let buf1 = buffer.alloc(10);
......@@ -97,14 +91,13 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0016
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(-5);
* @tc.author: liuganlin
*/
it("testAlloc0016", 0, function () {
try {
let buf = buffer.alloc(-5);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "size" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "size" must be number and the value cannot be negative. Received value is: -5');
}
});
......@@ -112,7 +105,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0017
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(10, string, encode);
* @tc.author: lengchangjing
*/
it("testAlloc0017", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -127,7 +119,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0018
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(0).fill(string, encode);
* @tc.author: lengchangjing
*/
it("testAlloc0018", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -142,7 +133,6 @@ describe('BufferTest', function () {
* @tc.name: testAlloc0019
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(5.5);
* @tc.author: liuganlin
*/
it("testAlloc0019", 0, function () {
let buf = buffer.alloc(5.5);
......@@ -153,7 +143,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0020
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(10);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0020", 0, function () {
let buf = buffer.allocUninitializedFromPool(10);
......@@ -164,7 +153,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0021
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(10).fill(string, encode);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0021", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -179,7 +167,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0022
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(10).fill(buffer);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0022", 0, function () {
let buf1 = buffer.allocUninitializedFromPool(10);
......@@ -191,7 +178,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0023
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(0);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0023", 0, function () {
let buf = buffer.allocUninitializedFromPool(0);
......@@ -202,7 +188,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0024
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(0).fill(string, encode);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0024", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -217,7 +202,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0025
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(10).fill(buffer);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0025", 0, function () {
let buf1 = buffer.allocUninitializedFromPool(10);
......@@ -229,14 +213,13 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0026
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(-5);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0026", 0, function () {
try {
let buf = buffer.allocUninitializedFromPool(-5);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "size" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "size" must be number and the value cannot be negative. Received value is: -5');
}
});
......@@ -244,7 +227,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitializedFromPool0029
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitializedFromPool(5.5);
* @tc.author: liuganlin
*/
it("testAllocUninitializedFromPool0029", 0, function () {
let buf = buffer.allocUninitializedFromPool(5.5);
......@@ -257,7 +239,6 @@ describe('BufferTest', function () {
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength("abcd");
* @tc.author: liuganlin
*/
it("testByteLength0030", 0, function () {
let byteLen = buffer.byteLength("abcd");
......@@ -270,7 +251,6 @@ describe('BufferTest', function () {
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength("测试");
* @tc.author: liuganlin
*/
it("testByteLength0031", 0, function () {
let byteLen = buffer.byteLength("测试");
......@@ -283,7 +263,6 @@ describe('BufferTest', function () {
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength("测试");
* @tc.author: liuganlin
*/
it("testByteLength0032", 0, function () {
let byteLen = buffer.byteLength("$&@*%");
......@@ -291,14 +270,13 @@ describe('BufferTest', function () {
});
/**
* @tc.name: testByteLength0032
* @tc.name: testByteLength0033
* @tc.desc: Returns the byte length of a string when encoded using `encoding`.
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength(string, encode);
* @tc.author: liuganlin
*/
it("testByteLength0032", 0, function () {
it("testByteLength0033", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
'utf16le', 'utf-16le', 'base64', 'base64url', 'hex'];
let result = [4, 4, 8, 8, 4, 4, 4, 8, 8, 3, 3, 2];
......@@ -308,13 +286,28 @@ describe('BufferTest', function () {
}
});
/**
* @tc.name: testByteLength0034
* @tc.desc: Returns the byte length of a string when encoded using `encoding`.
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength(10);
*/
it("testByteLength0034", 0, function () {
try {
let byteLen = buffer.byteLength(10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "string" must be string or Buffer, ArrayBuffer. Received value is: number');
}
});
/**
* @tc.name: testByteLength0035
* @tc.desc: Returns the byte length of a string when encoded using `encoding`.
* This is not the same as [`String.prototype.length`], which does not account
* for the encoding that is used to convert the string into bytes.
* For example: buffer.byteLength(arrayBuffer);
* @tc.author: liuganlin
*/
it("testByteLength0035", 0, function () {
let uintarr = new Uint8Array(2);
......@@ -328,7 +321,6 @@ describe('BufferTest', function () {
* @tc.name: testIsBuffer0040
* @tc.desc: Returns true if obj is a Buffer, false otherwise
* For example: buffer.isBuffer(buf);
* @tc.author: liuganlin
*/
it("testIsBuffer0040", 0, function () {
let buf = buffer.alloc(1);
......@@ -340,7 +332,6 @@ describe('BufferTest', function () {
* @tc.name: testIsBuffer0045
* @tc.desc: Returns true if obj is a Buffer, false otherwise
* For example: buffer.isBuffer(buf);
* @tc.author: liuganlin
*/
it("testIsBuffer0045", 0, function () {
let obj = new Object(1);
......@@ -352,7 +343,6 @@ describe('BufferTest', function () {
* @tc.name: testIsEncoding0050
* @tc.desc: Returns true if encoding is the name of a supported character encoding, or false otherwise.
* For example: buffer.isEncoding("utf8");
* @tc.author: liuganlin
*/
it("testIsEncoding0050", 0, function () {
let flag = buffer.isEncoding("utf8");
......@@ -363,7 +353,6 @@ describe('BufferTest', function () {
* @tc.name: testIsEncoding0053
* @tc.desc: Returns true if encoding is the name of a supported character encoding, or false otherwise.
* For example: buffer.isEncoding(encode);
* @tc.author: liuganlin
*/
it("testIsEncoding0053", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -378,7 +367,6 @@ describe('BufferTest', function () {
* @tc.name: testIsEncoding0056
* @tc.desc: Returns true if encoding is the name of a supported character encoding, or false otherwise.
* For example: buffer.isEncoding("gbk");
* @tc.author: liuganlin
*/
it("testIsEncoding0056", 0, function () {
let flag = buffer.isEncoding('gbk');
......@@ -391,7 +379,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1235");
* let res = buffer.compare(buf1, buf2);
* @tc.author: liuganlin
*/
it("testStaticCompare0060", 0, function () {
let buf1 = buffer.from("1236");
......@@ -406,7 +393,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1235");
* let res = buffer.compare(buf1, buf2);
* @tc.author: liuganlin
*/
it("testStaticCompare0061", 0, function () {
let buf1 = buffer.from("1235");
......@@ -421,7 +407,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("测试一");
* let buf2 = buffer.from("测试二");
* let res = buffer.compare(buf1, buf2);
* @tc.author: liuganlin
*/
it("testStaticCompare0062", 0, function () {
let buf1 = buffer.from("测试一");
......@@ -436,7 +421,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("测试$&*");
* let buf2 = buffer.from("测试$&*");
* let res = buffer.compare(buf1, buf2);
* @tc.author: liuganlin
*/
it("testStaticCompare0063", 0, function () {
let buf1 = buffer.from("测试$&*");
......@@ -446,20 +430,53 @@ describe('BufferTest', function () {
});
/**
* @tc.name: testStaticCompare0060
* @tc.name: testStaticCompare0064
* @tc.desc: Compares buf1 to buf2.
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1236");
* let res = buffer.compare(buf1, buf2);
* @tc.author: liuganlin
*/
it("testStaticCompare0065", 0, function () {
it("testStaticCompare0064", 0, function () {
let buf1 = buffer.from("1236");
let buf2 = buffer.from("1236");
let res = buffer.compare(buf1, buf2);
expect(res).assertEqual(0);
});
/**
* @tc.name: testStaticCompare0065
* @tc.desc: Compares buf1 to buf2.
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1236");
* let res = buffer.compare(buf1, buf2);
*/
it("testStaticCompare0065", 0, function () {
let buf2 = buffer.from("1236");
try {
let res = buffer.compare(10, buf2);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "buf1" must be Buffer or Uint8Array. Received value is: string');
}
});
/**
* @tc.name: testStaticCompare0066
* @tc.desc: Compares buf1 to buf2.
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1236");
* let res = buffer.compare(buf1, buf2);
*/
it("testStaticCompare0066", 0, function () {
let buf1 = buffer.from("1236");
try {
let res = buffer.compare(buf1, 10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "buf2" must be Buffer or Uint8Array. Received value is: string');
}
});
/**
* @tc.name: testConcat0070
* @tc.desc: Returns a new `Buffer` which is the result of concatenating
......@@ -467,7 +484,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1235");
* let buf = buffer.concat([buf1, buf2]);
* @tc.author: liuganlin
*/
it("testConcat0070", 0, function () {
let buf1 = buffer.from("1236");
......@@ -484,7 +500,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("测试");
* let buf2 = buffer.from("$&*");
* let buf = buffer.concat([buf1, buf2]);
* @tc.author: liuganlin
*/
it("testConcat0071", 0, function () {
let buf1 = buffer.from("测试");
......@@ -494,6 +509,23 @@ describe('BufferTest', function () {
expect(str).assertEqual("测试$&*");
});
/**
* @tc.name: testConcat0072
* @tc.desc: Returns a new `Buffer` which is the result of concatenating
* all the `Buffer`instances in the `list` together.
* For example: let buf1 = buffer.from("测试");
* let buf2 = buffer.from("$&*");
* let buf = buffer.concat([buf1, buf2]);
*/
it("testConcat0072", 0, function () {
try {
let buf = buffer.concat("test string");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "list" must be Array. Received value is: string');
}
});
/**
* @tc.name: testConcat0073
* @tc.desc: Returns a new `Buffer` which is the result of concatenating
......@@ -501,7 +533,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("123$");
* let buf2 = buffer.from("*35");
* let buf = buffer.concat([buf1, buf2]);
* @tc.author: liuganlin
*/
it("testConcat0073", 0, function () {
let buf1 = buffer.from("123$");
......@@ -512,6 +543,25 @@ describe('BufferTest', function () {
expect(str).assertEqual("123$*");
});
/**
* @tc.name: testConcat0074
* @tc.desc: Returns a new `Buffer` which is the result of concatenating
* all the `Buffer`instances in the `list` together.
* For example: let buf1 = buffer.from("123$");
* let buf2 = buffer.from("*35");
* let buf = buffer.concat([buf1, buf2]);
*/
it("testConcat0074", 0, function () {
let buf1 = buffer.from("123$");
let buf2 = buffer.from("*35");
try {
let buf = buffer.concat([buf1, buf2], -1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "totalLength" is out of range. It must be >= 0 and <= 4294967296. Received value is: -1');
}
});
/**
* @tc.name: testConcat0075
* @tc.desc: Returns a new `Buffer` which is the result of concatenating
......@@ -519,7 +569,6 @@ describe('BufferTest', function () {
* For example: let buf1 = buffer.from("1236");
* let buf2 = buffer.from("1235");
* let buf = buffer.concat([buf1, buf2]);
* @tc.author: liuganlin
*/
it("testConcat0075", 0, function () {
let uintarr = new Uint8Array(4);
......@@ -537,7 +586,6 @@ describe('BufferTest', function () {
* @tc.name: testTranscode0080
* @tc.desc: Re-encodes the given Buffer or Uint8Array instance from one character encoding to another.
* For example: buffer.transcode(buf1, "ascii", "ucs2");
* @tc.author: liuganlin
*/
it("testTranscode0080", 0, function () {
let buf1 = buffer.from("1236");
......@@ -550,7 +598,6 @@ describe('BufferTest', function () {
* @tc.name: testTranscode0081
* @tc.desc: Re-encodes the given Buffer or Uint8Array instance from one character encoding to another.
* For example: buffer.transcode(buf1, "ascii", "ucs2");
* @tc.author: liuganlin
*/
it("testTranscode0081", 0, function () {
let buf1 = buffer.from("测试");
......@@ -559,11 +606,54 @@ describe('BufferTest', function () {
expect(str).assertEqual("测试");
});
/**
* @tc.name: testTranscode0082
* @tc.desc: Re-encodes the given Buffer or Uint8Array instance from one character encoding to another.
* For example: buffer.transcode(buf1, "ascii", "ucs2");
*/
it("testTranscode0082", 0, function () {
try {
let buf = buffer.transcode(10, "utf8", "ucs2");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "source" must be Buffer or Uint8Array. Received value is: number');
}
});
/**
* @tc.name: testTranscode0083
* @tc.desc: Re-encodes the given Buffer or Uint8Array instance from one character encoding to another.
* For example: buffer.transcode(buf1, "ascii", "ucs2");
*/
it("testTranscode0083", 0, function () {
let buf1 = buffer.from("测试");
try {
let buf = buffer.transcode(buf1, 0, "ucs2");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "fromEnc" must be string. Received value is: number');
}
});
/**
* @tc.name: testTranscode0084
* @tc.desc: Re-encodes the given Buffer or Uint8Array instance from one character encoding to another.
* For example: buffer.transcode(buf1, "ascii", "ucs2");
*/
it("testTranscode0084", 0, function () {
let buf1 = buffer.from("测试");
try {
let buf = buffer.transcode(buf1, "utf8", 0);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "toEnc" must be string. Received value is: number');
}
});
/**
* @tc.name: testFill0090
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(3).fill("abc");
* @tc.author: liuganlin
*/
it("testFill0090", 0, function () {
let buf = buffer.alloc(3).fill("abc");
......@@ -575,7 +665,6 @@ describe('BufferTest', function () {
* @tc.name: testFill0091
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(10).fill('F1刘FG', 0, 10, 'hex');
* @tc.author: liuganlin
*/
it("testFill0091", 0, function () {
const buf1 = buffer.alloc(10).fill('F1刘FG', 0, 10, 'hex');
......@@ -611,7 +700,6 @@ describe('BufferTest', function () {
* @tc.name: testFill0092
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(3).fill("abc");
* @tc.author: liuganlin
*/
it("testFill0092", 0, function () {
let buf = buffer.alloc(3).fill("$*$");
......@@ -619,11 +707,53 @@ describe('BufferTest', function () {
expect(str).assertEqual("$*$");
});
/**
* @tc.name: testFill0093
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(3).fill("abc");
*/
it("testFill0093", 0, function () {
try {
let buf = buffer.alloc(3).fill("$*$", -1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 4294967296. Received value is: -1');
}
});
/**
* @tc.name: testFill0094
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(3).fill("abc");
*/
it("testFill0094", 0, function () {
try {
let buf = buffer.alloc(3).fill("$*$", 0, 5);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "end" is out of range. It must be >= 0 and <= 3. Received value is: 5');
}
});
/**
* @tc.name: testFill0095
* @tc.desc: Fills buf with the specified value. If the offset and end are not given, the entire buf will be filled.
* For example: buffer.alloc(3).fill("abc");
*/
it("testFill0095", 0, function () {
try {
let buf = buffer.alloc(3).fill("$*$", 0, 2, "code");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding code is unknown');
}
});
/**
* @tc.name: testWrite0100
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
* @tc.author: liuganlin
*/
it("testWrite0100", 0, function () {
let buf = buffer.alloc(5);
......@@ -637,7 +767,6 @@ describe('BufferTest', function () {
* @tc.name: testWrite0101
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
* @tc.author: liuganlin
*/
it("testWrite0101", 0, function () {
let buf = buffer.alloc(6);
......@@ -651,7 +780,6 @@ describe('BufferTest', function () {
* @tc.name: testWrite0102
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
* @tc.author: liuganlin
*/
it("testWrite0102", 0, function () {
let buf = buffer.alloc(8);
......@@ -661,13 +789,87 @@ describe('BufferTest', function () {
expect(str).assertEqual("!@#$%^&*");
});
/**
* @tc.name: testWrite0103
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
*/
it("testWrite0103", 0, function () {
let buf = buffer.alloc(8);
try {
let offset = buf.write("abcde", "utf9");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding utf9 is unknown');
}
});
/**
* @tc.name: testWrite0104
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
*/
it("testWrite0104", 0, function () {
let buf = buffer.alloc(8);
try {
let offset = buf.write(10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "str" must be string. Received value is: number');
}
});
/**
* @tc.name: testWrite0105
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
*/
it("testWrite0105", 0, function () {
let buf = buffer.alloc(8);
try {
let offset = buf.write("abcde", -1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 7. Received value is: -1');
}
});
/**
* @tc.name: testWrite0106
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
*/
it("testWrite0106", 0, function () {
let buf = buffer.alloc(8);
try {
let offset = buf.write("abcde", 1, 9);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "length" is out of range. It must be >= 0 and <= 8. Received value is: 9');
}
});
/**
* @tc.name: testWrite0107
* @tc.desc: Writes string to buf at offset according to the character encoding in encoding.
* For example: buf.write("abcde", "latin1");
*/
it("testWrite0107", 0, function () {
let buf = buffer.alloc(8);
try {
let offset = buf.write("abcde", 1, "code");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding code is unknown');
}
});
/**
* @tc.name: testCompare0110
* @tc.desc: Compares buf with target and returns a number indicating whether buf comes before, after,
* or is the same as target in sort order. Comparison is based on the actual sequence of
* bytes in each Buffer.
* For example: buf1.compare(buf2);
* @tc.author: liuganlin
*/
it("testCompare0110", 0, function () {
let buf1 = buffer.from("1236");
......@@ -676,11 +878,45 @@ describe('BufferTest', function () {
expect(res).assertEqual(1);
});
/**
* @tc.name: testCompare0111
* @tc.desc: Compares buf with target and returns a number indicating whether buf comes before, after,
* or is the same as target in sort order. Comparison is based on the actual sequence of
* bytes in each Buffer.
* For example: buf1.compare(buf2);
*/
it("testCompare0111", 0, function () {
let buf1 = buffer.from("1236");
try {
let res = buf1.compare(10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "target" must be Buffer or Uint8Array. Received value is: number');
}
});
/**
* @tc.name: testCompare0112
* @tc.desc: Compares buf with target and returns a number indicating whether buf comes before, after,
* or is the same as target in sort order. Comparison is based on the actual sequence of
* bytes in each Buffer.
* For example: buf1.compare(buf2);
*/
it("testCompare0112", 0, function () {
let buf1 = buffer.from("1236");
let buf2 = buffer.from("1235");
try {
let res = buf1.compare(buf2, -1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "targetStart" is out of range. It must be >= 0 and <= 4294967296. Received value is: -1');
}
});
/**
* @tc.name: testEquals0120
* @tc.desc: Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.
* For example: buf1.equals(buf2);
* @tc.author: liuganlin
*/
it("testEquals0120", 0, function () {
let buf1 = buffer.from("1236");
......@@ -693,7 +929,6 @@ describe('BufferTest', function () {
* @tc.name: testEquals0121
* @tc.desc: Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.
* For example: buf1.equals(buf2);
* @tc.author: liuganlin
*/
it("testEquals0121", 0, function () {
let buf1 = buffer.from("1236测试");
......@@ -706,7 +941,6 @@ describe('BufferTest', function () {
* @tc.name: testEquals0122
* @tc.desc: Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.
* For example: buf1.equals(buf2);
* @tc.author: liuganlin
*/
it("testEquals0122", 0, function () {
let buf1 = buffer.from("O@O");
......@@ -715,12 +949,26 @@ describe('BufferTest', function () {
expect(res).assertEqual(false);
});
/**
* @tc.name: testEquals0123
* @tc.desc: Returns true if both buf and otherBuffer have exactly the same bytes, false otherwise.
* For example: buf1.equals(buf2);
*/
it("testEquals0123", 0, function () {
let buf1 = buffer.from("1236");
try {
let res = buf1.equals("1236");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "otherBuffer" must be Buffer or Uint8Array. Received value is: string');
}
});
/**
* @tc.name: testSubarray0130
* @tc.desc: Returns a new Buffer that references the same memory as the original,
* but offset and cropped by the start and end indices.
* For example: buf1.subarray(0, 3);
* @tc.author: liuganlin
*/
it("testSubarray0130", 0, function () {
let buf1 = buffer.from("1236");
......@@ -734,7 +982,6 @@ describe('BufferTest', function () {
* @tc.desc: Returns a new Buffer that references the same memory as the original,
* but offset and cropped by the start and end indices.
* For example: buf1.subarray(3, 4);
* @tc.author: liuganlin
*/
it("testSubarray0133", 0, function () {
let buf1 = buffer.from("1236");
......@@ -748,7 +995,6 @@ describe('BufferTest', function () {
* @tc.desc: Returns a new Buffer that references the same memory as the original,
* but offset and cropped by the start and end indices.
* For example: buf1.subarray(-3, 0);
* @tc.author: liuganlin
*/
it("testSubarray0136", 0, function () {
let buf1 = buffer.from("1236");
......@@ -761,7 +1007,6 @@ describe('BufferTest', function () {
* @tc.desc: Returns a new Buffer that references the same memory as the original,
* but offset and cropped by the start and end indices.
* For example: buf1.subarray(6, 9);
* @tc.author: liuganlin
*/
it("testSubarray0139", 0, function () {
let buf1 = buffer.from("1236");
......@@ -776,7 +1021,6 @@ describe('BufferTest', function () {
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2);
* @tc.author: liuganlin
*/
it("testCopy0140", 0, function () {
let buf1 = buffer.from("1236");
......@@ -794,7 +1038,6 @@ describe('BufferTest', function () {
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2, targetStart, sourceStart, sourceEnd);
* @tc.author: liuganlin
*/
it("testCopy0141", 0, function () {
let buf1 = buffer.from("abcdefg");
......@@ -812,7 +1055,6 @@ describe('BufferTest', function () {
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2);
* @tc.author: liuganlin
*/
it("testCopy0143", 0, function () {
let buf1 = buffer.from("123656");
......@@ -823,6 +1065,43 @@ describe('BufferTest', function () {
expect(str).assertEqual("1236");
});
/**
* @tc.name: testCopy0144
* @tc.desc: Copies data from a region of buf to a region in target,
* even if the target memory region overlaps with buf.
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2);
*/
it("testCopy0144", 0, function () {
let buf1 = buffer.from("123656");
let buf2 = buffer.from("1235");
try {
let num = buf1.copy(buf2, -1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "targetStart" is out of range. It must be >= 0. Received value is: -1');
}
});
/**
* @tc.name: testCopy0145
* @tc.desc: Copies data from a region of buf to a region in target,
* even if the target memory region overlaps with buf.
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2);
*/
it("testCopy0145", 0, function () {
let buf1 = buffer.from("123656");
try {
let num = buf1.copy(10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "target" must be Buffer or Uint8Array. Received value is: number');
}
});
/**
* @tc.name: testCopy0146
* @tc.desc: Copies data from a region of buf to a region in target,
......@@ -830,7 +1109,6 @@ describe('BufferTest', function () {
* If sourceEnd is greater than the length of the target, the length of the target shall prevail,
* and the extra part will not be overwritten.
* For example: buf1.copy(buf2);
* @tc.author: liuganlin
*/
it("testCopy0146", 0, function () {
let buf1 = buffer.from("ab$#");
......@@ -845,7 +1123,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0150
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString();
* @tc.author: liuganlin
*/
it("testToString0150", 0, function () {
let buf1 = buffer.from("1236");
......@@ -857,7 +1134,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0151
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString();
* @tc.author: liuganlin
*/
it("testToString0151", 0, function () {
let buf1 = buffer.from("张三");
......@@ -869,7 +1145,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0152
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("binary");
* @tc.author: liuganlin
*/
it("testToString0152", 0, function () {
let buf1 = buffer.from("abc");
......@@ -881,7 +1156,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0153
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("binary");
* @tc.author: liuganlin
*/
it("testToString0153", 0, function () {
let buf1 = buffer.from("abc");
......@@ -893,7 +1167,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0154
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("base64");
* @tc.author: liuganlin
*/
it("testToString0154", 0, function () {
let buf1 = buffer.from("abc");
......@@ -905,7 +1178,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0155
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("hex");
* @tc.author: liuganlin
*/
it("testToString0155", 0, function () {
let buf1 = buffer.from("abc");
......@@ -917,7 +1189,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0156
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("latin1");
* @tc.author: liuganlin
*/
it("testToString0156", 0, function () {
let buf1 = buffer.from("abc");
......@@ -929,7 +1200,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0157
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("ucs2");
* @tc.author: liuganlin
*/
it("testToString0157", 0, function () {
let buf1 = buffer.from("abc");
......@@ -941,7 +1211,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0158
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("utf16le");
* @tc.author: liuganlin
*/
it("testToString0158", 0, function () {
let buf1 = buffer.from("abc");
......@@ -953,7 +1222,6 @@ describe('BufferTest', function () {
* @tc.name: testToString0159
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString();
* @tc.author: liuganlin
*/
it("testToString0159", 0, function () {
let buf1 = buffer.from("!@#$%^&*");
......@@ -965,7 +1233,6 @@ describe('BufferTest', function () {
* @tc.name: testToJSON0160
* @tc.desc: Returns a JSON representation of buf.
* For example: buf1.toJSON();
* @tc.author: liuganlin
*/
it("testToJSON0160", 0, function () {
let buf1 = buffer.from("1236");
......@@ -977,7 +1244,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0170
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.indexOf("3");
* @tc.author: liuganlin
*/
it("testIndexOf0170", 0, function () {
let buf1 = buffer.from("13236");
......@@ -990,7 +1256,6 @@ describe('BufferTest', function () {
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let buf1 = buffer.from("13236");
* buf1.indexOf("3", 2);
* @tc.author: liuganlin
*/
it("testIndexOf0171", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1002,7 +1267,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0173
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let index = buf1.indexOf(value);
* @tc.author: liuganlin
*/
it("testIndexOf0173", 0, function () {
let buf1 = buffer.from("13236235");
......@@ -1014,7 +1278,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0174
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let index = buf1.indexOf(value);
* @tc.author: liuganlin
*/
it("testIndexOf0174", 0, function () {
let buf1 = buffer.from("测试特殊字符$#@!");
......@@ -1026,7 +1289,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0175
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let index = buf1.indexOf(value, byteOffset);
* @tc.author: liuganlin
*/
it("testIndexOf0175", 0, function () {
let buf1 = buffer.from("13236235");
......@@ -1038,7 +1300,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0176
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.indexOf("a");
* @tc.author: liuganlin
*/
it("testIndexOf0176", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1050,7 +1311,6 @@ describe('BufferTest', function () {
* @tc.name: testIndexOf0177
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf = buffer.from("13236"); buf.indexOf("a", 0, "utf8");
* @tc.author: lengchangjing
*/
it("testIndexOf0177", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -1062,11 +1322,40 @@ describe('BufferTest', function () {
}
});
/**
* @tc.name: testIndexOf0178
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.indexOf("a");
*/
it("testIndexOf0178", 0, function () {
let buf1 = buffer.from("13236");
try {
let index = buf1.indexOf(true);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "value" must be string or number, Buffer, Uint8Array. Received value is: boolean');
}
});
/**
* @tc.name: testIndexOf0179
* @tc.desc: The index of the first occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.indexOf("a");
*/
it("testIndexOf0179", 0, function () {
let buf1 = buffer.from("13236");
try {
let index = buf1.indexOf("a", "code");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding code is unknown');
}
});
/**
* @tc.name: testLastIndexOf0180
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.lastIndexOf("3");
* @tc.author: liuganlin
*/
it("testLastIndexOf0180", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1078,7 +1367,6 @@ describe('BufferTest', function () {
* @tc.name: testLastIndexOf0181
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.lastIndexOf("3", 2);
* @tc.author: liuganlin
*/
it("testLastIndexOf0181", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1090,7 +1378,6 @@ describe('BufferTest', function () {
* @tc.name: testLastIndexOf0183
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236235"); buf1.lastIndexOf("23");
* @tc.author: liuganlin
*/
it("testLastIndexOf0183", 0, function () {
let buf1 = buffer.from("13236235");
......@@ -1102,7 +1389,6 @@ describe('BufferTest', function () {
* @tc.name: testLastIndexOf0184
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236235"); buf1.lastIndexOf("23", 3);
* @tc.author: liuganlin
*/
it("testLastIndexOf0184", 0, function () {
let buf1 = buffer.from("13236235");
......@@ -1114,7 +1400,6 @@ describe('BufferTest', function () {
* @tc.name: testLastIndexOf0186
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.lastIndexOf("a");
* @tc.author: liuganlin
*/
it("testLastIndexOf0186", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1126,7 +1411,6 @@ describe('BufferTest', function () {
* @tc.name: testLastIndexOf0187
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf = buffer.from("13236"); buf.lastIndexOf("a", 0, "utf8");
* @tc.author: lengchangjing
*/
it("testLastIndexOf0187", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -1138,11 +1422,40 @@ describe('BufferTest', function () {
}
});
/**
* @tc.name: testLastIndexOf0188
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.lastIndexOf("a");
*/
it("testLastIndexOf0188", 0, function () {
let buf1 = buffer.from("13236");
try {
let index = buf1.lastIndexOf(true);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "value" must be string or number, Buffer, Uint8Array. Received value is: boolean');
}
});
/**
* @tc.name: testLastIndexOf0189
* @tc.desc: The index of the last occurrence of value in buf.
* For example: let buf1 = buffer.from("13236"); buf1.lastIndexOf("a");
*/
it("testLastIndexOf0189", 0, function () {
let buf1 = buffer.from("13236");
try {
let index = buf1.lastIndexOf("a", "code");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding code is unknown');
}
});
/**
* @tc.name: testIncludes0190
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("3");
* @tc.author: liuganlin
*/
it("testIncludes0190", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1154,7 +1467,6 @@ describe('BufferTest', function () {
* @tc.name: testIncludes0191
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("3", 2);
* @tc.author: liuganlin
*/
it("testIncludes0191", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1166,7 +1478,6 @@ describe('BufferTest', function () {
* @tc.name: testIncludes0193
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("32");
* @tc.author: liuganlin
*/
it("testIncludes0193", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1178,7 +1489,6 @@ describe('BufferTest', function () {
* @tc.name: testIncludes0194
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("32", 2);
* @tc.author: liuganlin
*/
it("testIncludes0194", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1187,12 +1497,11 @@ describe('BufferTest', function () {
});
/**
* @tc.name: testIncludes0194
* @tc.name: testIncludes0195
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("32");
* @tc.author: liuganlin
*/
it("testIncludes0194", 0, function () {
it("testIncludes0195", 0, function () {
let buf1 = buffer.from("测试特殊字符$#@!");
let flag = buf1.includes("#@");
expect(flag).assertEqual(true);
......@@ -1204,7 +1513,6 @@ describe('BufferTest', function () {
* @tc.name: testIncludes0196
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("abc");
* @tc.author: liuganlin
*/
it("testIncludes0196", 0, function () {
let buf1 = buffer.from("13236");
......@@ -1216,7 +1524,6 @@ describe('BufferTest', function () {
* @tc.name: testIncludes0197
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("abc", 0, "utf8");
* @tc.author: lengchangjing
*/
it("testIncludes0197", 0, function () {
let encodeArr = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary',
......@@ -1228,11 +1535,25 @@ describe('BufferTest', function () {
}
});
/**
* @tc.name: testIncludes0198
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("abc");
*/
it("testIncludes0198", 0, function () {
let buf1 = buffer.from("13236");
try {
let flag = buf1.includes(true);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "value" must be string or number, Buffer, Uint8Array. Received value is: boolean');
}
});
/**
* @tc.name: testSwap160200
* @tc.desc: Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place.
* For example: buf1.swap16();
* @tc.author: liuganlin
*/
it("testSwap160200", 0, function () {
let buf1 = buffer.from("1323");
......@@ -1241,11 +1562,25 @@ describe('BufferTest', function () {
expect(str).assertEqual("33313332");
});
/**
* @tc.name: testSwap160201
* @tc.desc: Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place.
* For example: buf1.swap16();
*/
it("testSwap160201", 0, function () {
let buf1 = buffer.from("132");
try {
buf1.swap16();
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Buffer size must be a multiple of 16-bits');
}
});
/**
* @tc.name: testSwap320210
* @tc.desc: Interprets buf as an array of unsigned 32-bit integers and swaps the byte order in-place.
* For example: buf1.swap32();
* @tc.author: liuganlin
*/
it("testSwap320210", 0, function () {
let buf1 = buffer.from("1234");
......@@ -1254,11 +1589,25 @@ describe('BufferTest', function () {
expect(str).assertEqual("4321");
});
/**
* @tc.name: testswap320211
* @tc.desc: Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place.
* For example: buf1.swap32();
*/
it("testswap320211", 0, function () {
let buf1 = buffer.from("132");
try {
buf1.swap32();
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Buffer size must be a multiple of 32-bits');
}
});
/**
* @tc.name: testSwap640220
* @tc.desc: Interprets buf as an array of unsigned 64-bit integers and swaps the byte order in-place.
* For example: buf1.swap64();
* @tc.author: liuganlin
*/
it("testSwap640220", 0, function () {
let buf1 = buffer.from("12345678");
......@@ -1267,11 +1616,25 @@ describe('BufferTest', function () {
expect(str).assertEqual("87654321");
});
/**
* @tc.name: testSwap640221
* @tc.desc: Interprets buf as an array of unsigned 64-bit integers and swaps the byte order in-place.
* For example: buf1.swap64();
*/
it("testSwap640221", 0, function () {
let buf1 = buffer.from("1234567");
try {
buf1.swap64();
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Buffer size must be a multiple of 64-bits');
}
});
/**
* @tc.name: testKeys0230
* @tc.desc: Creates and returns an iterator of buf keys (indices).
* For example: buf1.keys();
* @tc.author: liuganlin
*/
it("testKeys0230", 0, function () {
let buf1 = buffer.from("1234");
......@@ -1287,7 +1650,6 @@ describe('BufferTest', function () {
* @tc.name: testKeys0235
* @tc.desc: Creates and returns an iterator of buf keys (indices).
* For example: buf1.keys();
* @tc.author: liuganlin
*/
it("testKeys0235", 0, function () {
let uarr = new Uint8Array(4);
......@@ -1308,7 +1670,6 @@ describe('BufferTest', function () {
* @tc.name: testValues0240
* @tc.desc: Creates and returns an iterator for buf values (bytes).
* For example: buf1.values();
* @tc.author: liuganlin
*/
it("testValues0240", 0, function () {
let buf1 = buffer.from("1234");
......@@ -1324,7 +1685,6 @@ describe('BufferTest', function () {
* @tc.name: testValues0245
* @tc.desc: Creates and returns an iterator for buf values (bytes).
* For example: buf1.values();
* @tc.author: liuganlin
*/
it("testValues0245", 0, function () {
let uarr = new Uint8Array(4);
......@@ -1345,7 +1705,6 @@ describe('BufferTest', function () {
* @tc.name: testEntries0250
* @tc.desc: Creates and returns an iterator of [index, byte] pairs from the contents of buf.
* For example: buf1.entries();
* @tc.author: liuganlin
*/
it("testEntries0250", 0, function () {
let buf1 = buffer.from("1234");
......@@ -1364,7 +1723,6 @@ describe('BufferTest', function () {
* @tc.desc: Creates and returns an iterator of [index, byte] pairs from the contents of buf
* which is contructed from an Uint8Array.
* For example: buf1.entries();
* @tc.author: liuganlin
*/
it("testEntries0255", 0, function () {
let uarr = new Uint8Array(4);
......@@ -1387,7 +1745,6 @@ describe('BufferTest', function () {
* @tc.name: testfrom0260
* @tc.desc: Copies the passed buffer data onto a new Buffer instance.
* For example: buffer.from(uint8Array);
* @tc.author: liuganlin
*/
it("testfrom0260", 0, function () {
let uarr = new Uint8Array(3);
......@@ -1404,7 +1761,6 @@ describe('BufferTest', function () {
* @tc.desc: Allocates a new Buffer using an array of bytes in the range 0 – 255.
* Array entries outside that range will be truncated to fit into it.
* For example: buffer.from(array);
* @tc.author: liuganlin
*/
it("testfrom0261", 0, function () {
const buf = buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
......@@ -1416,7 +1772,6 @@ describe('BufferTest', function () {
* @tc.name: testfrom0262
* @tc.desc: This creates a view of the ArrayBuffer without copying the underlying memory.
* For example: buffer.from(arrayBuffer);
* @tc.author: liuganlin
*/
it("testfrom0262", 0, function () {
const arr = new Uint8Array(2);
......@@ -1434,7 +1789,6 @@ describe('BufferTest', function () {
* @tc.name: testfrom0263
* @tc.desc: This creates a view of the ArrayBuffer without copying the underlying memory.
* For example: buffer.from(arrayBuffer, byteOffset);
* @tc.author: liuganlin
*/
it("testfrom0263", 0, function () {
const arr = new Uint8Array(2);
......@@ -1454,7 +1808,6 @@ describe('BufferTest', function () {
* @tc.name: testfrom0264
* @tc.desc: Copies the passed buffer data onto a new Buffer instance.
* For example: buffer2.from(buffer1);
* @tc.author: liuganlin
*/
it("testfrom0264", 0, function () {
const buf1 = buffer.from('buffer');
......@@ -1471,7 +1824,6 @@ describe('BufferTest', function () {
* @tc.desc: Creates a new Buffer containing string. The encoding parameter identifies the character encoding
* to be used when converting string into bytes.
* For example: buffer.from(string);
* @tc.author: liuganlin
*/
it("testfrom0265", 0, function () {
const buf1 = buffer.from('this is a test');
......@@ -1484,7 +1836,6 @@ describe('BufferTest', function () {
* @tc.desc: Creates a new Buffer containing string. The encoding parameter identifies the character encoding
* to be used when converting string into bytes.
* For example: buffer.from(string, encoding);
* @tc.author: liuganlin
*/
it("testfrom0266", 0, function () {
const buf1 = buffer.from('F1刘FG', 'hex');
......@@ -1537,7 +1888,6 @@ describe('BufferTest', function () {
* @tc.desc: For the object whose value returned by valueof() function is strictly equal to object
* or supports symbol To primitive object, a new buffer instance is created.
* For example: buffer.from(object);
* @tc.author: liuganlin
*/
it("testfrom0267", 0, function () {
const buf = buffer.from(new String('this is a test'));
......@@ -1550,7 +1900,6 @@ describe('BufferTest', function () {
* @tc.desc: For the object whose value returned by valueof() function is strictly equal to object
* or supports symbol To primitive object, a new buffer instance is created.
* For example: buffer.from(object);
* @tc.author: liuganlin
*/
it("testfrom0268", 0, function () {
class Foo {
......@@ -1567,7 +1916,6 @@ describe('BufferTest', function () {
* @tc.name: testBlobConstructor0270
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
* @tc.author: liuganlin
*/
it("testBlobConstructor0270", 0, async function () {
let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
......@@ -1581,7 +1929,6 @@ describe('BufferTest', function () {
* @tc.name: testBlobConstructor0271
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob2 = new buffer.Blob([arrBuf], { type: "new type", endings: "transparent" });
* @tc.author: liuganlin
*/
it("testBlobConstructor0271", 0, async function () {
let arrBuf = new ArrayBuffer(3);
......@@ -1599,7 +1946,6 @@ describe('BufferTest', function () {
* @tc.name: testBlobConstructor0272
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob2 = new buffer.Blob([uint8arr], { type: "new type", endings: "transparent" })
* @tc.author: liuganlin
*/
it("testBlobConstructor0272", 0, async function () {
let uint8arr = new Uint8Array(3);
......@@ -1616,7 +1962,6 @@ describe('BufferTest', function () {
* @tc.name: testBlobConstructor0273
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob2 = new buffer.Blob([view], { type: "new type", endings: "transparent" })
* @tc.author: liuganlin
*/
it("testBlobConstructor0273", 0, async function () {
let arrBuf = new ArrayBuffer(3);
......@@ -1636,7 +1981,6 @@ describe('BufferTest', function () {
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
* let blob = new buffer.Blob([blob2]);
* @tc.author: liuganlin
*/
it("testBlobConstructor0274", 0, async function () {
let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
......@@ -1646,11 +1990,38 @@ describe('BufferTest', function () {
});
});
/**
* @tc.name: testBlobConstructor0275
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
*/
it("testBlobConstructor0275", 0, async function () {
try {
let blob = new buffer.Blob(["a", "b", "c"], 10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "options" must be Object. Received value is: number');
}
});
/**
* @tc.name: testBlobConstructor0276
* @tc.desc: Creates a new Blob object containing a concatenation of the given sources.
* For example: let blob = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
*/
it("testBlobConstructor0276", 0, async function () {
try {
let blob = new buffer.Blob("abc", { type: "new type", endings: "transparent" });
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "sources" must be Iterable. Received value is: string');
}
});
/**
* @tc.name: testBlobArrayBuffer0280
* @tc.desc: Returns a promise that fulfills with an <ArrayBuffer> containing a copy of the Blob data.
* For example: let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
* @tc.author: liuganlin
*/
it("testBlobArrayBuffer0280", 0, async function () {
let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
......@@ -1666,7 +2037,6 @@ describe('BufferTest', function () {
* @tc.name: testBlobText0290
* @tc.desc: Returns a promise that fulfills with the contents of the Blob decoded as a UTF-8 string.
* For example: let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
* @tc.author: liuganlin
*/
it("testBlobText0290", 0, async function () {
let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
......@@ -1681,7 +2051,6 @@ describe('BufferTest', function () {
* The original Blob is not altered.
* For example: let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
* let blob = blob2.slice(0, 1);
* @tc.author: liuganlin
*/
it("testBlobSlice0300", 0, async function () {
let blob2 = new buffer.Blob(["a", "b", "c"], { type: "new type", endings: "transparent" });
......@@ -1699,7 +2068,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32BE(0x12345678, 0);
* @tc.author: liuganlin
*/
it("testWriteInt32BE0310", 0, function () {
let buf = buffer.alloc(4);
......@@ -1713,17 +2081,15 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 32-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt32BE0311", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32BE(0x12345678, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
/**
......@@ -1731,15 +2097,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 32-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt32BE0312", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32BE(0x123456789, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received value is: 4886718345');
}
});
......@@ -1748,15 +2113,30 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32BE(0x12345678, 1);
* @tc.author: liuganlin
*/
it("testWriteInt32BE0313", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32BE(0x12345678, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testWriteInt32BE0314
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32BE(0x12345678, 1);
*/
it("testWriteInt32BE0314", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32BE("string", 1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "value" must be number. Received value is: string');
}
});
......@@ -1765,13 +2145,11 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32LE(0x12345678, 0);
* @tc.author: liuganlin
*/
it("testWriteInt32LE0320", 0, function () {
let buf = buffer.alloc(4);
let ref = buf.writeInt32LE(0x12345678, 0);
expect(ref).assertEqual(4);
});
/**
......@@ -1779,15 +2157,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32LE(0x12345678, -1);
* @tc.author: liuganlin
*/
it("testWriteInt32LE0321", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32LE(0x12345678, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
......@@ -1796,15 +2173,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32LE(0x12345678, 0);
* @tc.author: liuganlin
*/
it("testWriteInt32LE0322", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32LE(0x123456789, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received value is: 4886718345');
}
});
......@@ -1813,15 +2189,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 32-bit integer.
* For example: let ref = buf.writeInt32LE(0x12345678, 1);
* @tc.author: liuganlin
*/
it("testWriteInt32LE0323", 0, function () {
let buf = buffer.alloc(4);
try {
let ref = buf.writeInt32LE(0x12345678, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -1830,7 +2205,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 16-bit integer.
* For example: let ref = buf.writeInt32LE(0x12345678, 0);
* @tc.author: liuganlin
*/
it("testWriteInt16BE0330", 0, function () {
let buf = buffer.alloc(2);
......@@ -1843,15 +2217,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16BE0331", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16BE(0x7bca, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
......@@ -1860,15 +2233,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16BE0332", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16BE(0x123456, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= -32768 and <= 32767. Received value is: 1193046');
}
});
......@@ -1877,15 +2249,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16BE0333", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16BE(0x7bca, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -1894,7 +2265,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 16-bit integer.
* For example: let ref = buf.writeInt16LE(0x1234, 0);
* @tc.author: liuganlin
*/
it("testWriteInt16LE0340", 0, function () {
let buf = buffer.alloc(2);
......@@ -1908,15 +2278,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16LE0341", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16LE(0x7bca, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
......@@ -1925,15 +2294,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16LE0342", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16LE(0x123456, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= -32768 and <= 32767. Received value is: 1193046');
}
});
......@@ -1942,15 +2310,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid signed 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt16LE0343", 0, function () {
let buf = buffer.alloc(2);
try {
let ref = buf.writeInt16LE(0x1234, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -1959,7 +2326,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset.
* value must be a valid signed 8-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt80350", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
......@@ -1972,15 +2338,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset.
* value must be a valid signed 8-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt80351", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
try {
let ref = buf.writeInt8(2, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: -1');
}
});
......@@ -1988,15 +2353,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteInt80352
* @tc.desc: Writes value to buf at the specified offset.value must be a valid signed 8-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt80352", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
try {
let ref = buf.writeInt8(0x13245, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= -128 and <= 127. Received value is: 78405');
}
});
......@@ -2004,7 +2368,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteInt80353
* @tc.desc: Writes value to buf at the specified offset.value must be a valid signed 8-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteInt80353", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
......@@ -2017,7 +2380,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUInt16BE0360", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2030,15 +2392,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 16-bit integer.
* For example: let ref = buf.writeUInt16BE(0xdeadfc, 0);
* @tc.author: liuganlin
*/
it("testWriteUInt16BE0361", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt16BE(0xdeadfc, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= 0 and <= 65535. Received value is: 14593532');
}
});
......@@ -2047,15 +2408,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 16-bit integer.
* For example: let ref = buf.writeUInt16BE(0xdead, -1);
* @tc.author: liuganlin
*/
it("testWriteUInt16BE0362", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt16BE(0xdead, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 2. Received value is: -1');
}
});
......@@ -2064,7 +2424,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 16-bit integer.
* For example: let ref = buf.writeUInt16LE(0xdead, 1);
* @tc.author: liuganlin
*/
it("testWriteUInt16BE0363", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2077,7 +2436,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 16-bit integer.
* For example: let ref = buf.writeUInt16LE(0xdead, 0);
* @tc.author: liuganlin
*/
it("testWriteUInt16LE0370", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2090,15 +2448,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUInt16LE0371", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt16LE(0xdeadfc, 0);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= 0 and <= 65535. Received value is: 14593532');
}
});
......@@ -2107,15 +2464,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 16-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUInt16LE0372", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt16LE(0xdead, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 2. Received value is: -1');
}
});
......@@ -2124,7 +2480,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 16-bit integer.
* For example: let ref = buf.writeUInt16LE(0xdead, 0);
* @tc.author: liuganlin
*/
it("testWriteUInt16LE0373", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2137,7 +2492,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 32-bit integer.
* For example: let ref = buf.writeUInt32BE(0xfeedface, 0);
* @tc.author: liuganlin
*/
it("testWriteUInt32BE0380", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2150,15 +2504,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 32-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUInt32BE0381", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt32BE(0xfeedface, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
......@@ -2167,15 +2520,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* The value must be a valid unsigned 32-bit integer.
* For example: let ref = buf.writeUInt32BE(0xfeedface, 1);
* @tc.author: liuganlin
*/
it("testWriteUInt32BE0382", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt32BE(0xfeedface, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2184,7 +2536,6 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 32-bit integer.
* For example: let ref = buf.writeUInt32LE(0xfeedface, 0);
* @tc.author: liuganlin
*/
it("testWriteUInt32LE0390", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2197,15 +2548,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 32-bit integer.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUInt32LE0391", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt32LE(0xfeedface, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: -1');
}
});
......@@ -2214,15 +2564,14 @@ describe('BufferTest', function () {
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* The value must be a valid unsigned 32-bit integer.
* For example: let ref = buf.writeUInt32LE(0xfeedface, 1);
* @tc.author: liuganlin
*/
it("testWriteUInt32LE0392", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt32LE(0xfeedface, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2230,7 +2579,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteUInt80400
* @tc.desc: Writes value to buf at the specified offset. value must be a valid unsigned 8-bit integer.
* For example: let ref = buf.writeUInt8(0x42, 3);
* @tc.author: liuganlin
*/
it("testWriteUInt80400", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2242,15 +2590,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteUInt80401
* @tc.desc: Writes value to buf at the specified offset. value must be a valid unsigned 8-bit integer.
* For example: let ref = buf.writeUInt8(0x42, -1);
* @tc.author: liuganlin
*/
it("testWriteUInt80401", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUInt8(0x42, -1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 3. Received value is: -1');
}
});
......@@ -2258,7 +2605,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteUInt80402
* @tc.desc: Writes value to buf at the specified offset. value must be a valid unsigned 8-bit integer.
* For example: let ref = buf.writeUInt8(0x42, 1);
* @tc.author: liuganlin
*/
it("testWriteUInt80402", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2270,7 +2616,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntBE0410
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as big-endian.
* For example: let ref = buf.writeUInt8(0x42, 3);
* @tc.author: liuganlin
*/
it("testWriteUIntBE0410", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2282,15 +2627,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntBE0411
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUIntBE0411", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUIntBE(0x13141516, 0, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= 0 and <= 255. Received value is: 320083222');
}
});
......@@ -2298,15 +2642,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntBE0412
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUIntBE0412", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUIntBE(0x13141516, 1, 4);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2314,7 +2657,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntLE0420
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example: let ref = buf.writeUIntLE(0x13141516, 0, 4);
* @tc.author: liuganlin
*/
it("testWriteUIntLE0420", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2326,15 +2668,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntLE0421
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUIntLE0421", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUIntLE(0x13141516, 0, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "value" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "value" is out of range. It must be >= 0 and <= 255. Received value is: 320083222');
}
});
......@@ -2342,15 +2683,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntLE0422
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUIntLE0422", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeUIntLE(0x13141516, 1, 4);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2358,7 +2698,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteUIntLE0423
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteUIntLE0423", 0, function () {
let buf = buffer.allocUninitializedFromPool(5);
......@@ -2370,7 +2709,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteIntBE0430
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteIntBE0430", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -2382,15 +2720,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteIntBE0431
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteIntBE0431", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
try {
let ref = buf.writeIntBE(0x1234567890ab, 1, 6);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2398,7 +2735,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteIntLE0440
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteIntLE0440", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -2410,15 +2746,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteIntLE0441
* @tc.desc: Writes byteLength bytes of value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteIntLE0441", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
try {
let ref = buf.writeIntLE(0x1234567890ab, 1, 6);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2426,7 +2761,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteDoubleBE0450
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteDoubleBE0450", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2438,15 +2772,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteDoubleBE0451
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteDoubleBE0451", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeDoubleBE(123.456, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2454,7 +2787,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteDoubleLE0460
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteDoubleLE0460", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2466,15 +2798,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteDoubleLE0461
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteDoubleLE0461", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeDoubleLE(123.456, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2482,7 +2813,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteFloatBE0470
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteFloatBE0470", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2494,15 +2824,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteFloatBE0471
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteFloatBE0471", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeFloatBE(0xcabcbcbc, 5);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 5');
}
});
......@@ -2510,7 +2839,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteFloatLE0480
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteFloatLE0480", 0, function () {
let buf = buffer.allocUninitializedFromPool(16);
......@@ -2522,15 +2850,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteFloatLE0481
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteFloatLE0481", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
try {
let ref = buf.writeFloatLE(0xcabcbcbc, 5);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 5');
}
});
......@@ -2538,7 +2865,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigInt64BE0490
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigInt64BE0490", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2550,15 +2876,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigInt64BE0491
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigInt64BE0491", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeBigInt64BE(0x0102030405060708n, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2566,7 +2891,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigInt64LE0500
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigInt64LE0500", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2578,15 +2902,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigInt64LE0501
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigInt64LE0501", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeBigInt64LE(0x0102030405060708n, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2594,7 +2917,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigUInt64BE0510
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigUInt64BE0510", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2606,15 +2928,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigUInt64BE0511
* @tc.desc: Writes value to buf at the specified offset as big-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigUInt64BE0511", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeBigUInt64BE(0xdecafafecacefaden, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2622,7 +2943,6 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigUInt64LE0520
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigUInt64LE0520", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -2634,15 +2954,14 @@ describe('BufferTest', function () {
* @tc.name: testWriteBigUInt64LE0521
* @tc.desc: Writes value to buf at the specified offset as little-endian.
* For example:
* @tc.author: liuganlin
*/
it("testWriteBigUInt64LE0521", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
try {
let ref = buf.writeBigUInt64LE(0xdecafafecacefaden, 1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2650,7 +2969,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt32BE0530
* @tc.desc: Reads a signed, big-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt32BE0530", 0, function () {
let buf = buffer.alloc(4);
......@@ -2663,7 +2981,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt32BE0531
* @tc.desc: Reads a signed, big-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt32BE0531", 0, function () {
let buf = buffer.alloc(4);
......@@ -2671,8 +2988,24 @@ describe('BufferTest', function () {
try {
let ref = buf.readInt32BE(1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadInt32BE0532
* @tc.desc: Reads a signed, big-endian 32-bit integer from buf at the specified offset.
* For example:
*/
it("testReadInt32BE0532", 0, function () {
let buf = buffer.alloc(4);
buf.writeInt32BE(0x12345678, 0);
try {
let ref = buf.readInt32BE("1");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "offset" must be number. Received value is: string');
}
});
......@@ -2680,7 +3013,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt32LE0540
* @tc.desc: Reads a signed, little-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt32LE0540", 0, function () {
let buf = buffer.alloc(4);
......@@ -2693,7 +3025,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt32LE0541
* @tc.desc: Reads a signed, little-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt32LE0541", 0, function () {
let buf = buffer.alloc(4);
......@@ -2701,8 +3032,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readInt32LE(1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2710,7 +3041,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt16BE0550
* @tc.desc: Reads a signed, big-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt16BE0550", 0, function () {
let buf = buffer.alloc(2);
......@@ -2723,7 +3053,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt16BE0551
* @tc.desc: Reads a signed, big-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt16BE0551", 0, function () {
let buf = buffer.alloc(2);
......@@ -2731,8 +3060,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readInt16BE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2740,7 +3069,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt16LE0560
* @tc.desc: Reads a signed, little-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt16LE0560", 0, function () {
let buf = buffer.alloc(2);
......@@ -2753,7 +3081,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt16LE0561
* @tc.desc: Reads a signed, little-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt16LE0561", 0, function () {
let buf = buffer.alloc(2);
......@@ -2761,8 +3088,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readInt16LE(1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2770,7 +3097,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt80570
* @tc.desc: Reads a signed 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt80570", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
......@@ -2783,7 +3109,6 @@ describe('BufferTest', function () {
* @tc.name: testReadInt80571
* @tc.desc: Reads a signed 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadInt80571", 0, function () {
let buf = buffer.allocUninitializedFromPool(2);
......@@ -2791,8 +3116,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readInt8(2).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: 2');
}
});
......@@ -2800,7 +3125,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt16BE0580
* @tc.desc: Reads an unsigned, big-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt16BE0580", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2813,7 +3137,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt16BE0581
* @tc.desc: Reads an unsigned, big-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt16BE0581", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2821,8 +3144,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUInt16BE(3).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 2. Received value is: 3');
}
});
......@@ -2830,7 +3153,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt16LE0590
* @tc.desc: Reads an unsigned, little-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt16LE0590", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2843,7 +3165,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt16LE0591
* @tc.desc: Reads an unsigned, little-endian 16-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt16LE0591", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2851,8 +3172,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUInt16LE(3).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 2. Received value is: 3');
}
});
......@@ -2860,7 +3181,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt32BE0600
* @tc.desc: Reads an unsigned, big-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt32BE0600", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2873,7 +3193,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt32BE0601
* @tc.desc: Reads an unsigned, big-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt32BE0601", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2881,8 +3200,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUInt32BE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2890,7 +3209,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt32LE0610
* @tc.desc: Reads an unsigned, little-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt32LE0610", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2903,7 +3221,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt32LE0611
* @tc.desc: Reads an unsigned, little-endian 32-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt32LE0611", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2911,8 +3228,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUInt32LE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
......@@ -2920,7 +3237,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt80620
* @tc.desc: Reads an unsigned 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt80620", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2933,7 +3249,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUInt80621
* @tc.desc: Reads an unsigned 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUInt80621", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2941,8 +3256,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUInt8(4).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 3. Received value is: 4');
}
});
......@@ -2950,7 +3265,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUIntBE0630
* @tc.desc: Reads an unsigned 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUIntBE0630", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2963,7 +3277,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUIntBE0631
* @tc.desc: Reads an unsigned 8-bit integer from buf at the specified offset.
* For example:
* @tc.author: liuganlin
*/
it("testReadUIntBE0631", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2971,8 +3284,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUIntBE(2, 3).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: 2');
}
});
......@@ -2980,7 +3293,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUIntLE0640
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as an unsigned, little-endian integer supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadUIntLE0640", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -2993,7 +3305,6 @@ describe('BufferTest', function () {
* @tc.name: testReadUIntLE0641
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as an unsigned, little-endian integer supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadUIntLE0641", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -3001,8 +3312,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readUIntLE(2, 3).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: 2');
}
});
......@@ -3010,7 +3321,6 @@ describe('BufferTest', function () {
* @tc.name: testReadIntBE0650
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as a big-endian, two's complement signed value supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadIntBE0650", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -3023,7 +3333,6 @@ describe('BufferTest', function () {
* @tc.name: testReadIntBE0651
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as a big-endian, two's complement signed value supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadIntBE0651", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -3031,8 +3340,8 @@ describe('BufferTest', function () {
try {
let ref = buf.readIntBE(2, 5).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: 2');
}
});
......@@ -3040,7 +3349,6 @@ describe('BufferTest', function () {
* @tc.name: testReadIntLE0660
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as a little-endian, two's complement signed value supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadIntLE0660", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -3053,7 +3361,6 @@ describe('BufferTest', function () {
* @tc.name: testReadIntLE0661
* @tc.desc: Reads byteLength number of bytes from buf at the specified offset and interprets
* the result as a little-endian, two's complement signed value supporting up to 48 bits of accuracy.
* @tc.author: liuganlin
*/
it("testReadIntLE0661", 0, function () {
let buf = buffer.allocUninitializedFromPool(6);
......@@ -3061,15 +3368,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readIntLE(2, 5).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 1. Received value is: 2');
}
});
/**
* @tc.name: testReadDoubleBE0670
* @tc.desc: Reads a 64-bit, big-endian double from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadDoubleBE0670", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3081,7 +3387,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadDoubleBE0671
* @tc.desc: Reads a 64-bit, big-endian double from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadDoubleBE0671", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3089,15 +3394,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readDoubleBE(1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadDoubleLE0680
* @tc.desc: Reads a 64-bit, little-endian double from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadDoubleLE0680", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3109,7 +3413,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadDoubleLE0681
* @tc.desc: Reads a 64-bit, little-endian double from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadDoubleLE0681", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3117,15 +3420,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readDoubleLE(1);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadFloatBE0690
* @tc.desc: Reads a 32-bit, big-endian float from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadFloatBE0690", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -3137,7 +3439,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadFloatBE0691
* @tc.desc: Reads a 32-bit, big-endian float from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadFloatBE0691", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -3145,15 +3446,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readFloatBE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadFloatLE0700
* @tc.desc: Reads a 32-bit, little-endian float from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadFloatLE0700", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -3165,7 +3465,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadFloatLE0701
* @tc.desc: Reads a 32-bit, little-endian float from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadFloatLE0701", 0, function () {
let buf = buffer.allocUninitializedFromPool(4);
......@@ -3173,15 +3472,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readFloatLE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadBigInt64BE0710
* @tc.desc: Reads a signed, big-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigInt64BE0710", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3193,7 +3491,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadBigInt64BE0711
* @tc.desc: Reads a signed, big-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigInt64BE0711", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3201,15 +3498,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readBigInt64BE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadBigInt64LE0720
* @tc.desc: Reads a signed, little-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigInt64LE0720", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3221,7 +3517,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadBigInt64LE0721
* @tc.desc: Reads a signed, little-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigInt64LE0721", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3229,15 +3524,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readBigInt64LE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadBigUInt64BE0730
* @tc.desc: Reads a unsigned, big-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigUInt64BE0730", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3249,7 +3543,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadBigUInt64BE0731
* @tc.desc: Reads a unsigned, big-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigUInt64BE0731", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3257,15 +3550,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readBigUInt64BE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testReadBigUInt64LE0740
* @tc.desc: Reads a unsigned, little-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigUInt64LE0740", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3277,7 +3569,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testReadBigUInt64LE0741
* @tc.desc: Reads a unsigned, little-endian 64-bit integer from buf at the specified offset.
* @tc.author: liuganlin
*/
it("testReadBigUInt64LE0741", 0, function () {
let buf = buffer.allocUninitializedFromPool(8);
......@@ -3285,15 +3576,14 @@ describe('BufferTest', function () {
try {
let ref = buf.readBigUInt64LE(1).toString(16);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "offset" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "offset" is out of range. It must be >= 0 and <= 0. Received value is: 1');
}
});
/**
* @tc.name: testBufferLength0750
* @tc.desc: Returns the number of bytes in buf.
* @tc.author: liuganlin
*/
it("testBufferLength0750", 0, function () {
let buf = buffer.from("1236");
......@@ -3304,18 +3594,20 @@ describe('BufferTest', function () {
/**
* @tc.name: testBufferLength0751
* @tc.desc: Returns the number of bytes in buf.
* @tc.author: liuganlin
*/
it("testBufferLength0751", 0, function () {
let buf = buffer.from("1236");
try {
buf.length = 10;
expect(buf.length).assertEqual(4);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Cannot set property length of Buffer which has only a getter');
}
});
/**
* @tc.name: testBufferLength0751
* @tc.desc: Returns the number of bytes in buf.
* @tc.author: liuganlin
*/
it("testBufferLength0752", 0, function () {
let buf = buffer.from("测试特殊字符$#@!");
......@@ -3326,7 +3618,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBufferByteOffset0755
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it("testBufferByteOffset0755", 0, function () {
let buf = buffer.from("1236");
......@@ -3337,7 +3628,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBufferByteOffset0756
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it("testBufferByteOffset0756", 0, function () {
let buf = buffer.alloc(10);
......@@ -3348,7 +3638,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBufferByteOffset0757
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it("testBufferByteOffset0757", 0, function () {
let buf = buffer.allocUninitializedFromPool(10);
......@@ -3359,7 +3648,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBufferByteOffset0758
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it("testBufferByteOffset0758", 0, function () {
let buf = buffer.allocUninitialized(10);
......@@ -3367,10 +3655,23 @@ describe('BufferTest', function () {
expect(offset >= 0).assertTrue();
});
/**
* @tc.name: testBufferByteOffset0759
* @tc.desc: Returns the offset of bytes in buf.
*/
it("testBufferByteOffset0759", 0, function () {
let buf = buffer.from("1236");
try {
buf.byteOffset = 3;
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Cannot set property byteOffset of Buffer which has only a getter');
}
});
/**
* @tc.name: testBlobSize0760
* @tc.desc: The total size of the Blob in bytes.
* @tc.author: liuganlin
*/
it("testBlobSize0760", 0, function () {
let blob = new buffer.Blob(["a", "b", "c"]);
......@@ -3381,7 +3682,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBlobSize0761
* @tc.desc: The total size of the Blob in bytes.
* @tc.author: liuganlin
*/
it("testBlobSize0761", 0, function () {
let blob = new buffer.Blob([]);
......@@ -3392,7 +3692,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBlobSize0762
* @tc.desc: The total size of the Blob in bytes.
* @tc.author: liuganlin
*/
it("testBlobSize0762", 0, function () {
let blob = new buffer.Blob(["测试", "$#", "c"]);
......@@ -3403,7 +3702,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBlobType0770
* @tc.desc: The content-type of the Blob.
* @tc.author: liuganlin
*/
it("testBlobType0770", 0, function () {
let blob = new buffer.Blob(["a", "b", "c"], { type: "mime", endings: "transparent" });
......@@ -3414,7 +3712,6 @@ describe('BufferTest', function () {
/**
* @tc.name: testBlobType0771
* @tc.desc: The content-type of the Blob.
* @tc.author: liuganlin
*/
it("testBlobType0771", 0, function () {
let blob = new buffer.Blob(["a", "b", "c"]);
......@@ -3426,7 +3723,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitialized0780
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitialized(10);
* @tc.author: liuganlin
*/
it("testAllocUninitialized0780", 0, function () {
let buf = buffer.allocUninitialized(10);
......@@ -3437,7 +3733,6 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitialized0781
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitialized(10);
* @tc.author: liuganlin
*/
it("testAllocUninitialized0781", 0, function () {
let buf = buffer.allocUninitialized(0);
......@@ -3448,14 +3743,80 @@ describe('BufferTest', function () {
* @tc.name: testAllocUninitialized0782
* @tc.desc: Allocates a new un-pooled Buffer for a fixed size bytes. The Buffer will not be initially filled.
* For example: buffer.allocUninitialized(-5);
* @tc.author: liuganlin
*/
it("testAllocUninitialized0782", 0, function () {
try {
let buf = buffer.allocUninitialized(-5);
} catch (err) {
expect(err.name).assertEqual('RangeError');
expect(err.message).assertEqual('The value of "size" is out of range');
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "size" must be number and the value cannot be negative. Received value is: -5');
}
});
/**
* @tc.name: testfrom0783
* @tc.desc: For the object whose value returned by valueof() function is strictly equal to object
* or supports symbol To primitive object, a new buffer instance is created.
* For example: buffer.from(object);
*/
it("testfrom0783", 0, function () {
try {
const buf = buffer.from(10);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "value" must be Buffer or ArrayBuffer, Array, Array-like. Received value is: string');
}
});
/**
* @tc.name: testBufferBuffer0784
* @tc.desc: Returns the number of bytes in buf.
*/
it("testBufferBuffer0784", 0, function () {
let buf = buffer.from("1236");
let buf1 = buffer.from("123");
try {
buf.buffer = buf1;
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('Cannot set property buffer of Buffer which has only a getter');
}
});
/**
* @tc.name: testToString0785
* @tc.desc: Decodes buf to a string according to the specified character encoding in encoding.
* For example: buf1.toString("binary");
*/
it("testToString0785", 0, function () {
let buf1 = buffer.from("abc");
try {
let str = buf1.toString("code");
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The type of "encoding" must be BufferEncoding. the encoding code is unknown');
}
});
/**
* @tc.name: testfrom0786
* @tc.desc: For the object whose value returned by valueof() function is strictly equal to object
* or supports symbol To primitive object, a new buffer instance is created.
* For example: buffer.from(object);
*/
it("testfrom0786", 0, function () {
let arrayBuffer = new ArrayBuffer(5);
let array = new Int8Array(arrayBuffer);
array[0] = '1';
array[1] = '2';
array[2] = '3';
array[3] = '4';
array[4] = '5';
try {
const buf = buffer.from(arrayBuffer, 6, 1);
} catch (err) {
expect(err.name).assertEqual('BusinessError');
expect(err.message).assertEqual('The value of "byteOffset" is out of range. It must be >= 0 and <= 5. Received value is: 6');
}
});
})}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册