Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vasudeva8 committed Jan 14, 2025
1 parent d9d1922 commit d3a135a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
9 changes: 8 additions & 1 deletion htslib/kstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,14 @@ static inline int kinsert_char(char c, size_t pos, kstring_t *s)
}
memmove(s->s + pos + 1, s->s + pos, s->l - pos);
s->s[pos] = c;
++s->l;
fprintf(stderr, "pos %llu - l %llu\n", pos, s->l);
s->s[++s->l] = 0;
fprintf(stderr, "++l %llu\n", s->l);

for (int i = 0; i < s->m; ++i) {
fprintf(stderr, "%c %d", s->s[i], s->s[i]);
}
fprintf(stderr, "\n");
return 0;
}

Expand Down
24 changes: 20 additions & 4 deletions test/test_kstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,11 @@ static int test_kinsertchar(void) {
return -1;
}
if (s.s[s.l] != '\0') {
fprintf(stderr, "No NUL termination on string from kinsert_char\n");
for (i = 0; i < s.m; ++i) {
fprintf(stderr, "%c %d ", s.s[i], s.s[i]);
}
fprintf(stderr, "length %llu/%llu\n", s.l, s.m);
fprintf(stderr, "No NUL termination on string from kinsert_char1\n");
ks_free(&s);
return -1;
}
Expand All @@ -492,7 +496,11 @@ static int test_kinsertchar(void) {
return -1;
}
if (t.s[t.l] != '\0') {
fprintf(stderr, "No NUL termination on string from kinsert_char\n");
for (i = 0; i < t.m; ++i) {
fprintf(stderr, "%c %d ", t.s[i], t.s[i]);
}
fprintf(stderr, "length %llu/%llu\n", t.l, t.m);
fprintf(stderr, "No NUL termination on string from kinsert_char2\n");
ks_free(&res); ks_free(&t);
return -1;
}
Expand Down Expand Up @@ -527,7 +535,11 @@ static int test_kinsertstr(void) {
return -1;
}
if (s.s[s.l] != '\0') {
fprintf(stderr, "No NUL termination on string from kinsert_str\n");
for (i = 0; i < s.m; ++i) {
fprintf(stderr, "%c %d ", s.s[i], s.s[i]);
}
fprintf(stderr, "length %llu/%llu\n", s.l, s.m);
fprintf(stderr, "No NUL termination on string from kinsert_str1\n");
return -1;
}
if (memcmp(s.s, tdata[i + 1].val, s.l + 1)) {
Expand All @@ -547,8 +559,12 @@ static int test_kinsertstr(void) {
return -1;
}
if (t.s[t.l] != '\0') {
for (i = 0; i < t.m; ++i) {
fprintf(stderr, "%c %d ", t.s[i], t.s[i]);
}
fprintf(stderr, "length %llu/%llu\n", t.l, t.m);
ks_free(&val); ks_free(&res);
fprintf(stderr, "No NUL termination on string from kinsert_str\n");
fprintf(stderr, "No NUL termination on string from kinsert_str2\n");
return -1;
}
if (memcmp(t.s, res.s, res.l+1)) {
Expand Down

0 comments on commit d3a135a

Please sign in to comment.