Skip to content
代码片段 群组 项目
提交 5753ba65 编辑于 作者: Bharat Dandu's avatar Bharat Dandu 提交者: Bharat Raju
浏览文件

Fixing the out of bounds dataview error when attribute is of size 3 bytes

上级 419f4795
No related branches found
No related tags found
无相关合并请求
......@@ -116,7 +116,7 @@ function convertFloatToBigEndian(value, size) {
* the given size. The value is returned in hex format and prefixed with '0x'.
*/
function convertIntToBigEndian(value, size) {
const arrayBuffer = size <= 4 ? new ArrayBuffer(size) : new ArrayBuffer(8)
const arrayBuffer = new ArrayBuffer(Math.pow(2, Math.ceil(Math.log2(size))))
const dataView = new DataView(arrayBuffer)
let i = 0
if (size == 1) {
......
......@@ -234,6 +234,32 @@ test(
testUtil.timeout.short()
)
test(
'Generated Macro little endian for attribute of size 3 bytes',
() => {
let options = { hash: { endian: 'little' } }
return zclHelper
.as_generated_default_macro('0x003840', 3, options)
.then((res) => {
return expect(res).toBe('0x40, 0x38, 0x00, ')
})
},
testUtil.timeout.short()
)
test(
'Generated Macro big endian for attribute of size 3 bytes',
() => {
let options = { hash: { endian: 'big' } }
return zclHelper
.as_generated_default_macro('0x003840', 3, options)
.then((res) => {
return expect(res).toBe(' 0x00, 0x38, 0x40,')
})
},
testUtil.timeout.short()
)
test(
'Generated Macro little endian',
() => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册