Ejemplo n.º 1
0
void
check(string msg, struct esb_s *data, string v)
{
    string b = esb_get_string(data);
    size_t l = 0;
    size_t alloc = 0;

    if (strcmp(b, v)) {
        fprintf(stderr, "ERROR: %s  content error  %s != %s\n", msg, b,
            v);
    }

    l = esb_string_len(data);

    if (l != strlen(v)) {
        fprintf(stderr, "ERROR: %s length error  %lu != %lu\n", msg,
            (unsigned long) l, (unsigned long) strlen(v));
    }
    alloc = esb_get_allocated_size(data);
    if (l > alloc) {
        fprintf(stderr, "ERROR: %s allocation error  %lu > %lu\n", msg,
            (unsigned long) l, (unsigned long) alloc);

    }

    return;
}
Ejemplo n.º 2
0
/* Get a copy of the internal data buffer */
string
esb_get_copy(struct esb_s *data)
{
    string copy = NULL;
    size_t len = esb_string_len(data);
    if (len) {
        copy = (string)malloc(len);
        strcpy(copy,esb_get_string(data));
    }

    return copy;
}
Ejemplo n.º 3
0
void
validate_esb(int instance,
   struct esb_s* d,
   size_t explen,
   size_t expalloc,
   const char *expout)
{
    printf("TEST instance %d\n",instance);
    if (esb_string_len(d) != explen) {
        ++failcount;
        printf("FAIL instance %d  slen %u explen %u\n",
            instance,(unsigned)esb_string_len(d),(unsigned)explen);
    }
    if (d->esb_allocated_size != expalloc) {
        ++failcount;
        printf("FAIL instance %d  alloclen %u expalloc %u\n",
            instance,(unsigned)d->esb_allocated_size,(unsigned)expalloc);
    }
    if(strcmp(esb_get_string(d),expout)) {
        ++failcount;
        printf("FAIL instance %d  str %s expstr %s\n",
            instance,esb_get_string(d),expout);
    }
}
Ejemplo n.º 4
0
void
validate_esb(int instance,
   struct esb_s* d,
   size_t explen,
   size_t expalloc,
   const char *expout,
   int line )
{
    if (esb_string_len(d) != explen) {
        ++failcount;
        printf("  FAIL instance %d  esb_string_len() %u explen %u line %d\n",
            instance,(unsigned)esb_string_len(d),(unsigned)explen,line);
    }
    if (d->esb_allocated_size != expalloc) {
        ++failcount;
        printf("  FAIL instance %d  esb_allocated_size  %u expalloc %u line %d\n",
            instance,(unsigned)d->esb_allocated_size,(unsigned)expalloc,line);
    }
    if(strcmp(esb_get_string(d),expout)) {
        ++failcount;
        printf("  FAIL instance %d esb_get_string %s expstr %s line %d\n",
            instance,esb_get_string(d),expout,line);
    }
}