mirror of
https://github.com/motajs/template.git
synced 2026-10-02 00:20:18 +08:00
test(07-10): 末步 set 用例改为断言 paramUsed 的外部可观测偏移
- paramUsed 为私有成员,其正确性只能通过下一条命令参数的写入偏移观测 - 增长与缩短两条末步用例补充参数缓冲区原始字节断言,使「末步起点回退」子缺陷在未修复时可直接失败
This commit is contained in:
parent
5b26539b00
commit
0c6812fcda
@ -317,6 +317,10 @@ describe('ReplayArray set index maintenance', () => {
|
||||
|
||||
array.add(3, [30]);
|
||||
expect(array.get(2)).toEqual({ command: 3, params: [30], index: 2 });
|
||||
// 末步 set 后 paramUsed 等于实际使用字节数(2 + 6),追加命令的参数紧接其后从第 8 字节起写入
|
||||
const params = new Uint8Array(array.getParamArray());
|
||||
expect(params[8]).toBe(1);
|
||||
expect(params[9]).toBe(30);
|
||||
});
|
||||
|
||||
// 验证末步 set 缩短参数后 paramUsed 相应减少,后续追加的参数落在正确偏移上
|
||||
@ -332,6 +336,10 @@ describe('ReplayArray set index maintenance', () => {
|
||||
|
||||
array.add(3, [30]);
|
||||
expect(array.get(2)).toEqual({ command: 3, params: [30], index: 2 });
|
||||
// 末步 set 后 paramUsed 回落到 2 + 2,追加命令的参数紧接其后从第 4 字节起写入
|
||||
const params = new Uint8Array(array.getParamArray());
|
||||
expect(params[4]).toBe(1);
|
||||
expect(params[5]).toBe(30);
|
||||
});
|
||||
|
||||
// 验证中间步 set 增长参数后,读取流逐条读回与按索引读回结果一致
|
||||
|
||||
Loading…
Reference in New Issue
Block a user