Skip to content

Commit

Permalink
Modify tests, appears to be more reflective of reality
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 11, 2024
1 parent 7e913f6 commit b7dd152
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/bgzFilehandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class BgzFilehandle {
length,
position,
)
const block = [] as Uint8Array[]
const blocks = [] as Uint8Array[]
for (
let blockNum = 0;
blockNum < blockPositions.length - 1;
Expand All @@ -107,11 +107,10 @@ export default class BgzFilehandle {
uncompressedPosition + uncompressedBuffer.length,
) - uncompressedPosition
if (sourceOffset >= 0 && sourceOffset < uncompressedBuffer.length) {
// uncompressedBuffer.copy(buf, destinationOffset, sourceOffset, sourceEnd)
block.push(uncompressedBuffer.subarray(sourceOffset, sourceEnd))
blocks.push(uncompressedBuffer.subarray(sourceOffset, sourceEnd))
}
}

return concatUint8Array(block)
return concatUint8Array(blocks)
}
}
2 changes: 1 addition & 1 deletion src/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function unzip(inputData: Uint8Array) {
result.set(chunks[i]!, offset)
offset += chunks[i]!.length
}
return Buffer.from(result)
return result
} catch (e) {
//cleanup error message
if (/incorrect header check/.exec(`${e}`)) {
Expand Down
32 changes: 20 additions & 12 deletions test/indexedfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ async function testRead(basename: string, length: number, position: number) {
expect(buf.length).toEqual(buf2.length)
expect(Array.from(buf)).toEqual(Array.from(buf2))

// const directStat = fs.fstatSync(fd)
// const myStat = await f.stat()
// expect(myStat.size).toEqual(directStat.size)
const directStat = fs.fstatSync(fd)
const myStat = await f.stat()
expect(myStat.size).toEqual(directStat.size)
}

test('can read gff3_with_syncs.gff3.gz 1', async () => {
Expand All @@ -34,12 +34,20 @@ test('can read gff3_with_syncs.gff3.gz 4', async () => {
await testRead('gff3_with_syncs.gff3', 2500, 0)
})
test('can read gff3_with_syncs.gff3.gz 5', async () => {
await testRead('gff3_with_syncs.gff3', 3000, 1)
})
// test('can read T_ko.2bit', async () => {
// await testRead('T_ko.2bit', 10, 0)
// await testRead('T_ko.2bit', 10000, 20000)
// await testRead('T_ko.2bit', 10000, 1)
// await testRead('T_ko.2bit', 10, 0)
// await testRead('T_ko.2bit', 10, 1000000)
// })
await testRead('gff3_with_syncs.gff3', 2545, 1)
})
test('can read T_ko.2bit 1', async () => {
await testRead('T_ko.2bit', 10, 0)
})
test('can read T_ko.2bit 2', async () => {
await testRead('T_ko.2bit', 10000, 20000)
})
test('can read T_ko.2bit 3', async () => {
await testRead('T_ko.2bit', 10000, 1)
})
test('can read T_ko.2bit 4', async () => {
await testRead('T_ko.2bit', 10, 0)
})
test('can read T_ko.2bit 5', async () => {
await testRead('T_ko.2bit', 0, 1000000)
})

0 comments on commit b7dd152

Please sign in to comment.