bam_hdr_t * setup_test_4(merged_header_t *merged_hdr) { const char* t4_init_text = "@HD\tVN:1.4\tSO:unknown\n" "@SQ\tSN:fish\tLN:133\tSP:frog\n" "@RG\tID:fish\tPU:out\n"; return setup_test(t4_init_text, init_refs, NELE(init_refs), test_4_trans_text, test_4_refs, NELE(test_4_refs), merged_hdr); }
bam_hdr_t * setup_test_5(merged_header_t *merged_hdr) { const char* t5_init_text = "@HD\tVN:1.4\tSO:unknown\n" "@SQ\tSN:fish\tLN:133\tSP:frog\n" "@RG\tID:fish\tPU:out\n" "@PG\tXX:dummyx\tID:fish\tDS:out\n" "@PG\tPP:fish\tID:hook\tDS:out\n"; return setup_test(t5_init_text, init_refs, NELE(init_refs), test_5_trans_text, test_5_refs, NELE(test_5_refs), merged_hdr); }
int t_double(int verbose) { uint8_t buf[9]; size_t i; int errors = 0; for (i = 0; i < NELE(tests_double); i++) { double f; if (verbose) { fprintf(stderr, "%s %.15g\n", to_hex(tests_double[i].u8, 8), tests_double[i].d); } f = le_to_double(tests_double[i].u8); if (f != tests_double[i].d) { fprintf(stderr, "Failed %s => %.15g; expected %.15g\n", to_hex(tests_double[i].u8, 8), f, tests_double[i].d); errors++; } f = le_to_double(tests_double[i].u8_unaligned + 1); if (f != tests_double[i].d) { fprintf(stderr, "Failed unaligned %s => %.15g; expected %.15g\n", to_hex(tests_double[i].u8_unaligned + 1, 8), f, tests_double[i].d); errors++; } double_to_le(tests_double[i].d, buf); if (memcmp(tests_double[i].u8, buf, 8) != 0) { fprintf(stderr, "Failed %.15g => %s; expected %s\n", tests_double[i].d, to_hex(buf, 8), to_hex(tests_double[i].u8, 8)); } double_to_le(tests_double[i].d, buf + 1); if (memcmp(tests_double[i].u8, buf + 1, 8) != 0) { fprintf(stderr, "Failed unaligned %.15g => %s; expected %s\n", tests_double[i].d, to_hex(buf + 1, 8), to_hex(tests_double[i].u8, 8)); } } return errors; }
int t_float(int verbose) { uint8_t buf[9]; size_t i; int errors = 0; for (i = 0; i < NELE(tests_float); i++) { float f; if (verbose) { fprintf(stderr, "%s %g\n", to_hex(tests_float[i].u8, 4), tests_float[i].f); } f = le_to_float(tests_float[i].u8); if (f != tests_float[i].f) { fprintf(stderr, "Failed %s => %g; expected %g\n", to_hex(tests_float[i].u8, 4), f, tests_float[i].f); errors++; } f = le_to_float(tests_float[i].u8_unaligned + 1); if (f != tests_float[i].f) { fprintf(stderr, "Failed unaligned %s => %g; expected %g\n", to_hex(tests_float[i].u8_unaligned + 1, 4), f, tests_float[i].f); errors++; } float_to_le(tests_float[i].f, buf); if (memcmp(tests_float[i].u8, buf, 4) != 0) { fprintf(stderr, "Failed %g => %s; expected %s\n", tests_float[i].f, to_hex(buf, 4), to_hex(tests_float[i].u8, 4)); } float_to_le(tests_float[i].f, buf + 1); if (memcmp(tests_float[i].u8, buf + 1, 4) != 0) { fprintf(stderr, "Failed unaligned %g => %s; expected %s\n", tests_float[i].f, to_hex(buf + 1, 4), to_hex(tests_float[i].u8, 4)); } } return errors; }
bam_hdr_t * setup_test_6(merged_header_t *merged_hdr) { return setup_test(init_text, init_refs, NELE(init_refs), test_6_trans_text, test_6_refs, NELE(test_6_refs), merged_hdr); }
static int t64_bit(int verbose) { uint8_t buf[9]; size_t i; int errors = 0; for (i = 0; i < NELE(tests_64_bit); i++) { uint64_t u64; int64_t i64; if (verbose) { fprintf(stderr, "%s %20"PRId64" %20"PRIu64"\n", to_hex(tests_64_bit[i].u8, 8), tests_64_bit[i].i64, tests_64_bit[i].u64); } u64 = le_to_u64(tests_64_bit[i].u8); if (u64 != tests_64_bit[i].u64) { fprintf(stderr, "Failed %s => %"PRIu64"; expected %"PRIu64"\n", to_hex(tests_64_bit[i].u8, 8), u64, tests_64_bit[i].u64); errors++; } i64 = le_to_i64(tests_64_bit[i].u8); if (i64 != tests_64_bit[i].i64) { fprintf(stderr, "Failed %s => %"PRId64"; expected %"PRId64"\n", to_hex(tests_64_bit[i].u8, 8), i64, tests_64_bit[i].i64); errors++; } u64 = le_to_u64(tests_64_bit[i].u8_unaligned + 1); if (u64 != tests_64_bit[i].u64) { fprintf(stderr, "Failed unaligned %s => %"PRIu64"; expected %"PRIu64"\n", to_hex(tests_64_bit[i].u8_unaligned + 1, 8), u64, tests_64_bit[i].u64); errors++; } i64 = le_to_i64(tests_64_bit[i].u8_unaligned + 1); if (i64 != tests_64_bit[i].i64) { fprintf(stderr, "Failed unaligned %s => %"PRId64"; expected %"PRId64"\n", to_hex(tests_64_bit[i].u8_unaligned + 1, 8), i64, tests_64_bit[i].i64); errors++; } u64_to_le(tests_64_bit[i].u64, buf); if (memcmp(buf, tests_64_bit[i].u8, 8) != 0) { fprintf(stderr, "Failed %"PRIu64" => %s; expected %s\n", tests_64_bit[i].u64, to_hex(buf, 8), to_hex(tests_64_bit[i].u8, 8)); errors++; } i64_to_le(tests_64_bit[i].i64, buf); if (memcmp(buf, tests_64_bit[i].u8, 8) != 0) { fprintf(stderr, "Failed %"PRId64" => %s; expected %s\n", tests_64_bit[i].i64, to_hex(buf, 8), to_hex(tests_64_bit[i].u8, 8)); errors++; } u64_to_le(tests_64_bit[i].u64, buf + 1); if (memcmp(buf + 1, tests_64_bit[i].u8, 8) != 0) { fprintf(stderr, "Failed unaligned %"PRIu64" => %s; expected %s\n", tests_64_bit[i].u64, to_hex(buf + 1, 8), to_hex(tests_64_bit[i].u8, 8)); errors++; } i64_to_le(tests_64_bit[i].i64, buf + 1); if (memcmp(buf + 1, tests_64_bit[i].u8, 8) != 0) { fprintf(stderr, "Failed unaligned %"PRId64" => %s; expected %s\n", tests_64_bit[i].i64, to_hex(buf + 1, 8), to_hex(tests_64_bit[i].u8, 8)); errors++; } } return errors; }
static int t32_bit(int verbose) { uint8_t buf[9]; size_t i; int errors = 0; for (i = 0; i < NELE(tests_32_bit); i++) { uint32_t u32; int32_t i32; if (verbose) { fprintf(stderr, "%s %11"PRId32" %11"PRIu32"\n", to_hex(tests_32_bit[i].u8, 4), tests_32_bit[i].i32, tests_32_bit[i].u32); } u32 = le_to_u32(tests_32_bit[i].u8); if (u32 != tests_32_bit[i].u32) { fprintf(stderr, "Failed %s => %"PRIu32"; expected %"PRIu32"\n", to_hex(tests_32_bit[i].u8, 4), u32, tests_32_bit[i].u32); errors++; } i32 = le_to_i32(tests_32_bit[i].u8); if (i32 != tests_32_bit[i].i32) { fprintf(stderr, "Failed %s => %"PRId32"; expected %"PRId32"\n", to_hex(tests_32_bit[i].u8, 4), i32, tests_32_bit[i].i32); errors++; } u32 = le_to_u32(tests_32_bit[i].u8_unaligned + 1); if (u32 != tests_32_bit[i].u32) { fprintf(stderr, "Failed unaligned %s => %"PRIu32"; expected %"PRIu32"\n", to_hex(tests_32_bit[i].u8_unaligned + 1, 4), u32, tests_32_bit[i].u32); errors++; } i32 = le_to_i32(tests_32_bit[i].u8_unaligned + 1); if (i32 != tests_32_bit[i].i32) { fprintf(stderr, "Failed unaligned %s => %"PRId32"; expected %"PRId32"\n", to_hex(tests_32_bit[i].u8_unaligned + 1, 4), i32, tests_32_bit[i].i32); errors++; } u32_to_le(tests_32_bit[i].u32, buf); if (memcmp(buf, tests_32_bit[i].u8, 4) != 0) { fprintf(stderr, "Failed %"PRIu32" => %s; expected %s\n", tests_32_bit[i].u32, to_hex(buf, 4), to_hex(tests_32_bit[i].u8, 4)); errors++; } i32_to_le(tests_32_bit[i].i32, buf); if (memcmp(buf, tests_32_bit[i].u8, 4) != 0) { fprintf(stderr, "Failed %"PRId32" => %s; expected %s\n", tests_32_bit[i].i32, to_hex(buf, 4), to_hex(tests_32_bit[i].u8, 4)); errors++; } u32_to_le(tests_32_bit[i].u32, buf + 1); if (memcmp(buf + 1, tests_32_bit[i].u8, 4) != 0) { fprintf(stderr, "Failed unaligned %"PRIu32" => %s; expected %s\n", tests_32_bit[i].u32, to_hex(buf + 1, 4), to_hex(tests_32_bit[i].u8, 4)); errors++; } i32_to_le(tests_32_bit[i].i32, buf + 1); if (memcmp(buf + 1, tests_32_bit[i].u8, 4) != 0) { fprintf(stderr, "Failed unaligned %"PRId32" => %s; expected %s\n", tests_32_bit[i].i32, to_hex(buf + 1, 4), to_hex(tests_32_bit[i].u8, 4)); errors++; } } return errors; }
static int t16_bit(int verbose) { uint8_t buf[9]; size_t i; int errors = 0; for (i = 0; i < NELE(tests_16_bit); i++) { uint16_t u16; int16_t i16; if (verbose) { fprintf(stderr, "%s %6"PRId16" %6"PRId16"\n", to_hex(tests_16_bit[i].u8, 2), tests_16_bit[i].i16, tests_16_bit[i].u16); } u16 = le_to_u16(tests_16_bit[i].u8); if (u16 != tests_16_bit[i].u16) { fprintf(stderr, "Failed %s => %"PRIu16"; expected %"PRIu16"\n", to_hex(tests_16_bit[i].u8, 2), u16, tests_16_bit[i].u16); errors++; } i16 = le_to_i16(tests_16_bit[i].u8); if (i16 != tests_16_bit[i].i16) { fprintf(stderr, "Failed %s => %"PRId16"; expected %"PRId16"\n", to_hex(tests_16_bit[i].u8, 2), i16, tests_16_bit[i].i16); errors++; } u16 = le_to_u16(tests_16_bit[i].u8_unaligned + 1); if (u16 != tests_16_bit[i].u16) { fprintf(stderr, "Failed unaligned %s => %"PRIu16"; expected %"PRIu16"\n", to_hex(tests_16_bit[i].u8_unaligned + 1, 2), u16, tests_16_bit[i].u16); errors++; } i16 = le_to_i16(tests_16_bit[i].u8_unaligned + 1); if (i16 != tests_16_bit[i].i16) { fprintf(stderr, "Failed unaligned %s => %"PRId16"; expected %"PRId16"\n", to_hex(tests_16_bit[i].u8_unaligned + 1, 2), i16, tests_16_bit[i].i16); errors++; } u16_to_le(tests_16_bit[i].u16, buf); if (memcmp(buf, tests_16_bit[i].u8, 2) != 0) { fprintf(stderr, "Failed %"PRIu16" => %s; expected %s\n", tests_16_bit[i].u16, to_hex(buf, 2), to_hex(tests_16_bit[i].u8, 2)); errors++; } i16_to_le(tests_16_bit[i].i16, buf); if (memcmp(buf, tests_16_bit[i].u8, 2) != 0) { fprintf(stderr, "Failed %"PRId16" => %s; expected %s\n", tests_16_bit[i].i16, to_hex(buf, 2), to_hex(tests_16_bit[i].u8, 2)); errors++; } u16_to_le(tests_16_bit[i].u16, buf + 1); if (memcmp(buf + 1, tests_16_bit[i].u8, 2) != 0) { fprintf(stderr, "Failed unaligned %"PRIu16" => %s; expected %s\n", tests_16_bit[i].u16, to_hex(buf + 1, 2), to_hex(tests_16_bit[i].u8, 2)); errors++; } i16_to_le(tests_16_bit[i].i16, buf + 1); if (memcmp(buf + 1, tests_16_bit[i].u8, 2) != 0) { fprintf(stderr, "Failed unaligned %"PRId16" => %s; expected %s\n", tests_16_bit[i].i16, to_hex(buf + 1, 2), to_hex(tests_16_bit[i].u8, 2)); errors++; } } return errors; }
static int aux_fields1(void) { static const char sam[] = "data:," "@SQ\tSN:one\tLN:1000\n" "@SQ\tSN:two\tLN:500\n" "r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXA:A:k\tXi:i:37\tXf:f:" xstr(PI) "\tXd:d:" xstr(E) "\tXZ:Z:" HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,+2\tB0:B:i,-2147483648,-1,0,1,2147483647\tB1:B:I,0,1,2147483648,4294967295\tB2:B:s,-32768,-1,0,1,32767\tB3:B:S,0,1,32768,65535\tB4:B:c,-128,-1,0,1,127\tB5:B:C,0,1,127,255\tBf:B:f,-3.14159,2.71828\tZZ:i:1000000\tF2:d:2.46801\tY1:i:-2147483648\tY2:i:-2147483647\tY3:i:-1\tY4:i:0\tY5:i:1\tY6:i:2147483647\tY7:i:2147483648\tY8:i:4294967295\n"; // Canonical form of the alignment record above, as output by sam_format1() static const char r1[] = "r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXi:i:37\tXf:f:3.14159\tXd:d:2.71828\tXZ:Z:" NEW_HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,2\tB0:B:i,-2147483648,-1,0,1,2147483647\tB1:B:I,0,1,2147483648,4294967295\tB2:B:s,-32768,-1,0,1,32767\tB3:B:S,0,1,32768,65535\tB4:B:c,-128,-1,0,1,127\tB5:B:C,0,1,127,255\tBf:B:f,-3.14159,2.71828\tZZ:i:1000000\tF2:f:9.8765\tY1:i:-2147483648\tY2:i:-2147483647\tY3:i:-1\tY4:i:0\tY5:i:1\tY6:i:2147483647\tY7:i:2147483648\tY8:i:4294967295\tN0:i:-1234\tN1:i:1234\tN2:i:-2\tN3:i:3\tF1:f:4.5678\tN4:B:S,65535,32768,1,0\tN5:i:4242"; samFile *in = sam_open(sam, "r"); bam_hdr_t *header = sam_hdr_read(in); bam1_t *aln = bam_init1(); uint8_t *p; kstring_t ks = { 0, 0, NULL }; int64_t b0vals[5] = { -2147483648LL,-1,0,1,2147483647LL }; // i int64_t b1vals[4] = { 0,1,2147483648LL,4294967295LL }; // I int64_t b2vals[5] = { -32768,-1,0,1,32767 }; // s int64_t b3vals[4] = { 0,1,32768,65535 }; // S int64_t b4vals[5] = { -128,-1,0,1,127 }; // c int64_t b5vals[4] = { 0,1,127,255 }; // C // NB: Floats not doubles below! // See https://randomascii.wordpress.com/2012/06/26/doubles-are-not-floats-so-dont-compare-them/ float bfvals[2] = { -3.14159f, 2.71828f }; int8_t n4v1[] = { -128, -64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, 127 }; uint32_t n4v2[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1234, 5678, 1U << 31, 0 }; int16_t n4v3[] = { -32768, -1, 0, 1, 32767 }; float n4v4[] = { 0, 1, 2, 10, 20, 30, 1.5, -2.5 }; uint8_t n4v5[] = { 0, 255 }; int32_t n4v6[] = { -2147483647 - 1, 10, -1, 0, 1, 2147483647 }; uint16_t n4v7[] = { 65535, 32768, 1, 0 }; int32_t ival = -1234; uint32_t uval = 1234; float f1 = 4.5678; float f2 = 9.8765; size_t nvals, i; if (sam_read1(in, header, aln) >= 0) { if ((p = check_bam_aux_get(aln, "XA", 'A')) && bam_aux2A(p) != 'k') fail("XA field is '%c', expected 'k'", bam_aux2A(p)); bam_aux_del(aln,p); if (bam_aux_get(aln,"XA")) fail("XA field was not deleted"); if ((p = check_bam_aux_get(aln, "Xi", 'C')) && bam_aux2i(p) != 37) fail("Xi field is %"PRId64", expected 37", bam_aux2i(p)); if ((p = check_bam_aux_get(aln, "Xf", 'f')) && fabs(bam_aux2f(p) - PI) > 1E-6) fail("Xf field is %.12f, expected pi", bam_aux2f(p)); if ((p = check_bam_aux_get(aln, "Xd", 'd')) && fabs(bam_aux2f(p) - E) > 1E-6) fail("Xf field is %.12f, expected e", bam_aux2f(p)); if ((p = check_bam_aux_get(aln, "XZ", 'Z')) && strcmp(bam_aux2Z(p), HELLO) != 0) fail("XZ field is \"%s\", expected \"%s\"", bam_aux2Z(p), HELLO); bam_aux_update_str(aln,"XZ",strlen(NEW_HELLO)+1,NEW_HELLO); if ((p = check_bam_aux_get(aln, "XZ", 'Z')) && strcmp(bam_aux2Z(p), NEW_HELLO) != 0) fail("XZ field is \"%s\", expected \"%s\"", bam_aux2Z(p), NEW_HELLO); if ((p = check_bam_aux_get(aln, "XH", 'H')) && strcmp(bam_aux2Z(p), BEEF) != 0) fail("XH field is \"%s\", expected \"%s\"", bam_aux2Z(p), BEEF); if ((p = check_bam_aux_get(aln, "XB", 'B')) && ! (memcmp(p, "Bc", 2) == 0 && memcmp(p + 2, "\x03\x00\x00\x00\xfe\x00\x02", 7) == 0)) fail("XB field is %c,..., expected c,-2,0,+2", p[1]); check_int_B_array(aln, "B0", NELE(b0vals), b0vals); check_int_B_array(aln, "B1", NELE(b1vals), b1vals); check_int_B_array(aln, "B2", NELE(b2vals), b2vals); check_int_B_array(aln, "B3", NELE(b3vals), b3vals); check_int_B_array(aln, "B4", NELE(b4vals), b4vals); check_int_B_array(aln, "B5", NELE(b5vals), b5vals); nvals = NELE(bfvals); if ((p = check_bam_aux_get(aln, "Bf", 'B')) != NULL) { if (bam_auxB_len(p) != nvals) fail("Wrong length reported for Bf field, got %d, expected %zd\n", bam_auxB_len(p), nvals); for (i = 0; i < nvals; i++) { if (bam_auxB2f(p, i) != bfvals[i]) { fail("Wrong value from bam_auxB2f for Bf field index %zd, " "got %f expected %f\n", i, bam_auxB2f(p, i), bfvals[i]); } } } if ((p = check_bam_aux_get(aln, "ZZ", 'I')) && bam_aux2i(p) != 1000000) fail("ZZ field is %"PRId64", expected 1000000", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y1")) && bam_aux2i(p) != -2147483647-1) fail("Y1 field is %"PRId64", expected -2^31", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y2")) && bam_aux2i(p) != -2147483647) fail("Y2 field is %"PRId64", expected -2^31+1", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y3")) && bam_aux2i(p) != -1) fail("Y3 field is %"PRId64", expected -1", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y4")) && bam_aux2i(p) != 0) fail("Y4 field is %"PRId64", expected 0", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y5")) && bam_aux2i(p) != 1) fail("Y5 field is %"PRId64", expected 1", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y6")) && bam_aux2i(p) != 2147483647) fail("Y6 field is %"PRId64", expected 2^31-1", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y7")) && bam_aux2i(p) != 2147483648LL) fail("Y7 field is %"PRId64", expected 2^31", bam_aux2i(p)); if ((p = bam_aux_get(aln, "Y8")) && bam_aux2i(p) != 4294967295LL) fail("Y8 field is %"PRId64", expected 2^32-1", bam_aux2i(p)); // Try appending some new tags if (bam_aux_append(aln, "N0", 'i', sizeof(ival), (uint8_t *) &ival) != 0) fail("Failed to append N0:i tag"); if ((p = bam_aux_get(aln, "N0")) && bam_aux2i(p) != ival) fail("N0 field is %"PRId64", expected %d", bam_aux2i(p), ival); if (bam_aux_append(aln, "N1", 'I', sizeof(uval), (uint8_t *) &uval) != 0) fail("failed to append N1:I tag"); if ((p = bam_aux_get(aln, "N1")) && bam_aux2i(p) != uval) fail("N1 field is %"PRId64", expected %u", bam_aux2i(p), uval); // Append tags with bam_aux_update_int() if (bam_aux_update_int(aln, "N2", -2) < 0) fail("failed to append N2:c tag"); if (bam_aux_update_int(aln, "N3", 3) < 0) fail("failed to append N3:C tag"); p = bam_aux_get(aln, "N2"); if (!p) fail("failed to retrieve N2 tag"); else if (*p != 'c' || bam_aux2i(p) != -2) fail("N2 field is %c:%"PRId64", expected c:-2", *p, bam_aux2i(p)); p = bam_aux_get(aln, "N3"); if (!p) fail("failed to retrieve N3 tag"); else if (*p != 'C' || bam_aux2i(p) != 3) fail("N3 field is %c:%"PRId64", expected C:3", *p, bam_aux2i(p)); // Try changing values with bam_aux_update_int() i = test_update_int(aln, "N2", 2, 'C', "N3", 3, 'C'); if (i == 0) test_update_int(aln, "N2", 1234, 'S', "N3", 3, 'C'); if (i == 0) test_update_int(aln, "N2", -1, 's', "N3", 3, 'C'); if (i == 0) test_update_int(aln, "N2", 4294967295U, 'I', "N3", 3, 'C'); if (i == 0) test_update_int(aln, "N2", -2, 'i', "N3", 3, 'C'); // Append a value with bam_aux_update_float() if (bam_aux_update_float(aln, "F1", f1) < 0) fail("append F1:f tag"); p = bam_aux_get(aln, "F1"); if (!p) fail("retrieve F1 tag"); else if (*p != 'f' || bam_aux2f(p) != f1) fail("F1 field is %c:%e, expected f:%e", *p, bam_aux2f(p), f1); // Change a double tag to a float if (bam_aux_update_float(aln, "F2", f2) < 0) fail("update F2 tag"); p = bam_aux_get(aln, "F2"); if (!p) fail("retrieve F2 tag"); else if (*p != 'f' || bam_aux2f(p) != f2) fail("F2 field is %c:%e, expected f:%e", *p, bam_aux2f(p), f2); // Check the next one is intact too p = bam_aux_get(aln, "Y1"); if (!p) fail("retrieve Y1 tag"); else if (*p != 'i' && bam_aux2i(p) != -2147483647-1) fail("Y1 field is %"PRId64", expected -2^31", bam_aux2i(p)); // bam_aux_update_array tests // append a new array i = test_update_array(aln, "N4", 'c', NELE(n4v1), n4v1, "\0\0", 0, 0); // Add a sentinal to check resizes work if (i == 0) i = test_update_int(aln, "N5", 4242, 'S', "\0\0", 0, 0); // alter the array tag a few times if (i == 0) i = test_update_array(aln, "N4", 'I', NELE(n4v2), n4v2, "N5", 4242, 'S'); if (i == 0) i = test_update_array(aln, "N4", 's', NELE(n4v3), n4v3, "N5", 4242, 'S'); if (i == 0) i = test_update_array(aln, "N4", 'f', NELE(n4v4), n4v4, "N5", 4242, 'S'); if (i == 0) i = test_update_array(aln, "N4", 'c', NELE(n4v5), n4v5, "N5", 4242, 'S'); if (i == 0) i = test_update_array(aln, "N4", 'i', NELE(n4v6), n4v6, "N5", 4242, 'S'); if (i == 0) i = test_update_array(aln, "N4", 'S', NELE(n4v7), n4v7, "N5", 4242, 'S'); if (sam_format1(header, aln, &ks) < 0) fail("can't format record"); if (strcmp(ks.s, r1) != 0) fail("record formatted incorrectly: \"%s\"", ks.s); free(ks.s); } else fail("can't read record"); bam_destroy1(aln); bam_hdr_destroy(header); sam_close(in); return 1; }