annotate src/lib/test-str.c @ 22664:fea53c2725c0

director: Fix director_max_parallel_moves/kicks type Should be uint, not time.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 09 Nov 2017 12:24:16 +0200
parents 2e2563132d5f
children cb108f786fb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21390
2e2563132d5f Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 21021
diff changeset
1 /* Copyright (c) 2012-2017 Dovecot authors, see the included COPYING file */
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "test-lib.h"
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "str.h"
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5
21020
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
6 static void test_str_append(void)
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
7 {
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
8 string_t *str = t_str_new(32);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
9 string_t *str2 = t_str_new(32);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
10
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
11 test_begin("str_append_*()");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
12 str_append(str, "foo");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
13 str_append_c(str, '|');
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
14 str_append_c(str, '\0');
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
15 test_assert(str->used == 5 && memcmp(str_data(str), "foo|\0", 5) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
16
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
17 str_append(str2, "sec");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
18 str_append_c(str2, '\0');
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
19 str_append(str2, "ond");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
20 str_append_str(str, str2);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
21 test_assert(str->used == 5+7 && memcmp(str_data(str), "foo|\0sec\0ond", 5+7) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
22
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
23 test_end();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
24 }
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
25
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 static void test_str_c(void)
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 {
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 string_t *str;
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 unsigned int i, j;
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 test_begin("str_c()");
17204
49c7cc58fb1b liblib: Fixed crash using str_c() in different stack frame with str_new(0) allocated string.
Timo Sirainen <tss@iki.fi>
parents: 17132
diff changeset
32 str = t_str_new(0);
49c7cc58fb1b liblib: Fixed crash using str_c() in different stack frame with str_new(0) allocated string.
Timo Sirainen <tss@iki.fi>
parents: 17132
diff changeset
33 T_BEGIN {
49c7cc58fb1b liblib: Fixed crash using str_c() in different stack frame with str_new(0) allocated string.
Timo Sirainen <tss@iki.fi>
parents: 17132
diff changeset
34 (void)str_c(str);
49c7cc58fb1b liblib: Fixed crash using str_c() in different stack frame with str_new(0) allocated string.
Timo Sirainen <tss@iki.fi>
parents: 17132
diff changeset
35 } T_END;
49c7cc58fb1b liblib: Fixed crash using str_c() in different stack frame with str_new(0) allocated string.
Timo Sirainen <tss@iki.fi>
parents: 17132
diff changeset
36
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 for (i = 0; i < 32; i++) T_BEGIN {
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38 str = t_str_new(15);
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 for (j = 0; j < i; j++)
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 str_append_c(str, 'x');
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 T_BEGIN {
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42 (void)str_c(str);
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 } T_END;
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 } T_END;
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 test_end();
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 }
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47
21020
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
48 static void test_str_insert(void)
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
49 {
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
50 string_t *str = t_str_new(32);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
51
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
52 test_begin("str_insert()");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
53 str_insert(str, 0, "foo");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
54 str_insert(str, 3, ">");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
55 str_insert(str, 3, "bar");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
56 str_insert(str, 0, "<");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
57 test_assert(str->used == 8 && memcmp(str_data(str), "<foobar>", 8) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
58
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
59 str_insert(str, 10, "!");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
60 test_assert(str->used == 11 && memcmp(str_data(str), "<foobar>\0\0!", 11) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
61
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
62 test_end();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
63 }
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
64
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
65 static void test_str_delete(void)
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
66 {
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
67 string_t *str = t_str_new(32);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
68
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
69 test_begin("str_delete()");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
70 str_delete(str, 0, 100);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
71 str_append(str, "123456");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
72 str_delete(str, 0, 1);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
73 str_delete(str, 4, 1);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
74 str_delete(str, 1, 1);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
75 test_assert(str->used == 3 && memcmp(str_data(str), "245", 3) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
76
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
77 str_delete(str, 1, 2);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
78 test_assert(str->used == 1 && memcmp(str_data(str), "2", 1) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
79
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
80 str_append(str, "bar");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
81 str_delete(str, 1, 100);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
82 test_assert(str->used == 1 && memcmp(str_data(str), "2", 1) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
83
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
84 test_end();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
85 }
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
86
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
87 static void test_str_append_n(void)
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
88 {
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
89 string_t *str = t_str_new(32);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
90
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
91 test_begin("str_append_n()");
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
92 str_append_n(str, "foo", 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
93 test_assert(str->used == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
94
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
95 str_append_n(str, "\0foo", 4);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
96 test_assert(str->used == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
97
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
98 str_append_n(str, "foo", 3);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
99 test_assert(str->used == 3 && memcmp(str_data(str), "foo", 3) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
100 str_truncate(str, 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
101
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
102 str_append_n(str, "foo", 2);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
103 test_assert(str->used == 2 && memcmp(str_data(str), "fo", 2) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
104 str_truncate(str, 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
105
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
106 str_append_n(str, "foo\0bar", 7);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
107 test_assert(str->used == 3 && memcmp(str_data(str), "foo", 3) == 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
108 str_truncate(str, 0);
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
109 test_end();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
110 }
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
111
21021
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
112 static void test_str_truncate(void)
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
113 {
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
114 string_t *str = t_str_new(8);
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
115 int i;
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
116
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
117 test_begin("str_truncate()");
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
118 str_append(str, "123456");
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
119 for (i = 100; i >= 6; i--) {
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
120 str_truncate(str, i);
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
121 test_assert_idx(str_len(str) == 6, i);
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
122 }
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
123 for (; i >= 0; i--) {
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
124 str_truncate(str, i);
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
125 test_assert_idx(str_len(str) == (unsigned int)i, i);
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
126 }
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
127 test_end();
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
128 }
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
129
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
130 void test_str(void)
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
131 {
21020
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
132 test_str_append();
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 test_str_c();
21020
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
134 test_str_insert();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
135 test_str_delete();
ae7aa8fe8c17 lib: Added more unit tests to str_*()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
136 test_str_append_n();
21021
bda524026533 lib: Fix str_truncate() when string size is already smaller.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21020
diff changeset
137 test_str_truncate();
15790
c762a9af72c1 buffer: Always keep +1 byte available for str_c()'s NUL.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 }