Beispiel #1
0
END_TEST

START_TEST(copy2) {
    const char *t = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    str_append_chars(s, t);
    str_copy_to_chars(s, &copy);

    ck_assert_msg(strcmp(copy, t) == 0, "%s == %s", copy, t);
}
Beispiel #2
0
END_TEST

START_TEST(append_chars_long) {
    s = str_new(NULL);

    const char *t = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    str_append_chars(s, t);

    ck_assert_msg(strcmp(s->str, t) == 0, "%s == %s", s->str, t);
    ck_assert_msg(s->len == strlen(t), "str's len member is %d", strlen(t));
}
Beispiel #3
0
END_TEST

START_TEST(append_chars_to_non_empty_string) {
    s = str_new("a");

    const char *t = "a";
    str_append_chars(s, t);

    ck_assert_msg(strcmp(s->str, "aa") == 0, "%s == %s", s->str, "aa");
    ck_assert_msg(s->len == 2, "str's len member is %d", 2);
}
Beispiel #4
0
str_t * _any_tostring(data_t *self, char *name, arguments_t *args) {
  str_t  *ret;
  int     ix;

  (void) self;
  (void) name;

  ret = str_from_data(arguments_get_arg(args, 0));
  for (ix = 1; ix < arguments_args_size(args); ix++) {
    str_append_chars(ret, arguments_arg_tostring(args, ix));
  }
  return ret;
}
Beispiel #5
0
str_t * list_tostr(list_t *list) {
  str_t *ret;
  str_t *catted;

  if (list) {
    if (!list -> size) {
      ret = str_wrap("<>");
    } else {
      ret = str_copy_chars("<");
      catted = str_join(", ", list, _list_reduce_chars);
      if (ret && catted) {
        str_append(ret, catted);
        str_append_chars(ret, ">");
      }
      str_free(catted);
    }
  } else {
    ret = str_wrap("Null");
  }
  return ret;
}