fix(ConstTypes): size should be same as in type
This commit is contained in:
@ -14,6 +14,8 @@ describe(ConstArray.name, () => {
|
||||
dv = sizedDataView(sizeof(ConstArray(2), Number))
|
||||
expect(16).toEqual(dv.byteLength)
|
||||
|
||||
expect(() => serialize(dv, [1, 2, 3], ConstArray(2), Number)).toThrow()
|
||||
|
||||
serialize(dv, [1, 2], ConstArray(2), Number)
|
||||
expectDataViewEqual(dv, expected)
|
||||
})
|
||||
|
||||
@ -13,6 +13,8 @@ describe(ConstDataView.name, () => {
|
||||
|
||||
actual = new DataView(buffer, 2, 2)
|
||||
|
||||
expect(() => serialize(actual, dv, ConstDataView(1))).toThrow()
|
||||
|
||||
serialize(actual, dv, ConstDataView(2))
|
||||
expectDataViewEqual(new DataView(actual.buffer), expected)
|
||||
})
|
||||
|
||||
@ -10,7 +10,8 @@ describe(ConstString.name, () => {
|
||||
|
||||
dv = sizedDataView(5)
|
||||
|
||||
serialize(dv, 'hello', ConstString(3))
|
||||
expect(() => serialize(dv, 'hello', ConstString(3))).toThrow()
|
||||
serialize(dv, 'hel', ConstString(3))
|
||||
expectDataViewEqual(dv, expected)
|
||||
})
|
||||
|
||||
|
||||
@ -80,13 +80,13 @@ describe(Struct.name, () => {
|
||||
const token = {
|
||||
data: { name: 'sek1ro' },
|
||||
header: { expires: 1 },
|
||||
signature: sizedDataView(4),
|
||||
signature: filledDataView([0xFF, 0xFF, 0xFF, 0xFF]),
|
||||
}
|
||||
const token_dv = filledDataView([
|
||||
0x00, 0x00, 0x00, 0x10, // data_head
|
||||
// header
|
||||
0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // header.expires
|
||||
0x00, 0x00, 0x00, 0x00, // signature
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // signature
|
||||
// data
|
||||
0x00, 0x00, 0x00, 0x04, // data.name_head
|
||||
// data.name
|
||||
|
||||
Reference in New Issue
Block a user