Browse Source

very basic ccp4 spec test

Alexander Rose 5 years ago
parent
commit
78c7664be3
2 changed files with 25 additions and 8 deletions
  1. 25 7
      src/mol-io/reader/_spec/ccp4.spec.ts
  2. 0 1
      src/mol-io/reader/_spec/dcd.spec.ts

+ 25 - 7
src/mol-io/reader/_spec/ccp4.spec.ts

@@ -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)
     });
 });

+ 0 - 1
src/mol-io/reader/_spec/dcd.spec.ts

@@ -10,7 +10,6 @@ function createDcdData() {
     const data = new Uint8Array(4 * 128)
 
     const dv = new DataView(data.buffer)
-    // const intView = new Int32Array(data.buffer, 0, 23)
 
     // set little endian
     dv.setInt32(0, 84)