Lines Matching refs:sb
28 static ssize_t add_string(struct strbuf *sb, const char *s) {
29 return strbuf_add_string(sb, s, strlen(s));
33 struct strbuf *sb;
37 sb = strbuf_new();
39 a = add_string(sb, "waldo");
40 b = add_string(sb, "foo");
41 c = add_string(sb, "bar");
42 d = add_string(sb, "waldo"); /* duplicate */
43 e = add_string(sb, "aldo"); /* duplicate */
44 f = add_string(sb, "do"); /* duplicate */
45 g = add_string(sb, "waldorf"); /* not a duplicate: matches from tail */
48 l = strv_parse_nulstr(sb->buf, sb->len);
56 assert_se(sb->nodes_count == 5); /* root + 4 non-duplicates */
57 assert_se(sb->dedup_count == 3);
58 assert_se(sb->in_count == 7);
60 assert_se(sb->in_len == 29); /* length of all strings added */
61 assert_se(sb->dedup_len == 11); /* length of all strings duplicated */
62 assert_se(sb->len == 23); /* buffer length: in - dedup + \0 for each node */
73 assert_se(streq(sb->buf + a, "waldo"));
74 assert_se(streq(sb->buf + b, "foo"));
75 assert_se(streq(sb->buf + c, "bar"));
76 assert_se(streq(sb->buf + d, "waldo"));
77 assert_se(streq(sb->buf + e, "aldo"));
78 assert_se(streq(sb->buf + f, "do"));
79 assert_se(streq(sb->buf + g, "waldorf"));
81 strbuf_complete(sb);
82 assert_se(sb->root == NULL);
84 strbuf_cleanup(sb);