diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-29 20:04:21 +0100 | 
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-29 20:04:21 +0100 | 
| commit | d62a11bb35bc42f86b3e41b69e6fd930c20d69b1 (patch) | |
| tree | 4188b754068b74954825272582c5106ae615d3f5 | |
| parent | 4d01a66401468121037444401a5e598168e3f708 (diff) | |
| download | alisp-d62a11bb35bc42f86b3e41b69e6fd930c20d69b1.tar.gz alisp-d62a11bb35bc42f86b3e41b69e6fd930c20d69b1.tar.bz2 alisp-d62a11bb35bc42f86b3e41b69e6fd930c20d69b1.zip  | |
Modify main.c to better test stream
| -rw-r--r-- | main.c | 23 | 
1 files changed, 10 insertions, 13 deletions
@@ -33,39 +33,36 @@ int main(void)    // stream_init_file(&stream, "stdin", stdin);    /// test 1 -  // printf("[debug]: setup stream pipe\n"); -  // do -  // { -  //   printf("%s[%lu]: `%c`\n", stream.name, stream.position, -  //          stream_next(&stream)); -  // } while (!stream_eoc(&stream)); -  // printf("%lu/%lu\n", stream.position, stream_size(&stream)); +  while (!stream_eoc(&stream)) +  { +    printf("%s[%lu]: `%c`\n", stream.name, stream.position, +           stream_next(&stream)); +  } +  printf("%lu/%lu\n", stream.position, stream_size(&stream));    /// test 2 -  sv_t a  = stream_substr(&stream, 100); -  sv_t a_ = sv_copy(a); -  printf("`" PR_SV "`\n", SV_FMT(a)); +  stream.position = 0; +  sv_t a          = stream_substr(&stream, 100); +  sv_t a_         = sv_copy(a);    stream_seek(&stream, 100);    sv_t b  = stream_substr_abs(&stream, 0, 100);    sv_t b_ = sv_copy(b); -  printf("`" PR_SV "`\n", SV_FMT(b));    printf("a=b ? %s\na_=b_ ? %s\n",           memcmp(&a, &b, sizeof(a)) == 0 ? "yes" : "no",           a_.size == b_.size && strncmp(a_.data, b_.data, a_.size) == 0 ? "yes"                                                                         : "no");    sv_t c  = stream_substr(&stream, 100);    sv_t c_ = sv_copy(c); -  printf("`" PR_SV "`\n", SV_FMT(c));    stream_seek(&stream, 100);    sv_t d  = stream_substr_abs(&stream, stream.position - 100, 100);    sv_t d_ = sv_copy(d); -  printf("`" PR_SV "`\n", SV_FMT(d));    printf("c=d ? %s\nc_=d_ ? %s\n",           memcmp(&c, &d, sizeof(a)) == 0 ? "yes" : "no",           c_.size == d_.size && strncmp(c_.data, d_.data, c_.size) == 0 ? "yes"                                                                         : "no");    printf("eos?=%s\n", stream_eos(&stream) ? "yes" : "no"); +  printf("eoc?=%s\n", stream_eoc(&stream) ? "yes" : "no");    stream_stop(&stream);    // fclose(fp);  | 
