mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-08 01:01:36 +08:00
32 lines
952 B
TypeScript
32 lines
952 B
TypeScript
import { ArrayBufferCursor } from '../../ArrayBufferCursor';
|
|
import { parseQst, writeQst } from './qst';
|
|
import { walkQstFiles } from '../../../../test/src/utils';
|
|
|
|
/**
|
|
* Parse a file, convert the resulting structure to QST again and check whether the end result is equal to the original.
|
|
*/
|
|
test('parseQst and writeQst', () => {
|
|
walkQstFiles((_filePath, _fileName, fileContent) => {
|
|
const origQst = new ArrayBufferCursor(fileContent.buffer, true);
|
|
const origQuest = parseQst(origQst);
|
|
|
|
if (origQuest) {
|
|
const testQst = writeQst(origQuest);
|
|
origQst.seekStart(0);
|
|
|
|
expect(testQst.size).toBe(origQst.size);
|
|
|
|
let match = true;
|
|
|
|
while (origQst.bytesLeft) {
|
|
if (testQst.u8() !== origQst.u8()) {
|
|
match = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
expect(match).toBe(true);
|
|
}
|
|
});
|
|
});
|