|
@@ -6,19 +6,37 @@
|
|
|
|
|
|
import * as CCP4 from '../ccp4/parser'
|
|
|
|
|
|
-const ccp4Buffer = new Uint8Array(4 * 64)
|
|
|
+function createCcp4Data() {
|
|
|
+ const data = new Uint8Array(4 * 256 + 6)
|
|
|
+
|
|
|
+ const dv = new DataView(data.buffer)
|
|
|
+
|
|
|
+ dv.setInt8(52 * 4, 'M'.charCodeAt(0))
|
|
|
+ dv.setInt8(52 * 4 + 1, 'A'.charCodeAt(0))
|
|
|
+ dv.setInt8(52 * 4 + 2, 'P'.charCodeAt(0))
|
|
|
+ dv.setInt8(52 * 4 + 3, ' '.charCodeAt(0))
|
|
|
+
|
|
|
+ dv.setInt32(0 * 4, 1) // NC
|
|
|
+ dv.setInt32(1 * 4, 2) // NR
|
|
|
+ dv.setInt32(2 * 4, 3) // NS
|
|
|
+
|
|
|
+ return data
|
|
|
+}
|
|
|
|
|
|
describe('ccp4 reader', () => {
|
|
|
it('basic', async () => {
|
|
|
- const parsed = await CCP4.parse(ccp4Buffer).run();
|
|
|
+ const data = createCcp4Data()
|
|
|
+ const parsed = await CCP4.parse(data).run();
|
|
|
|
|
|
if (parsed.isError) {
|
|
|
- console.log(parsed)
|
|
|
- return;
|
|
|
+ throw new Error(parsed.message)
|
|
|
}
|
|
|
- // const ccp4File = parsed.result;
|
|
|
- // const { header, values } = ccp4File;
|
|
|
|
|
|
- // TODO
|
|
|
+ const ccp4File = parsed.result;
|
|
|
+ const { header } = ccp4File;
|
|
|
+
|
|
|
+ expect(header.NC).toBe(1)
|
|
|
+ expect(header.NR).toBe(2)
|
|
|
+ expect(header.NS).toBe(3)
|
|
|
});
|
|
|
});
|