-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.c
33 lines (28 loc) · 877 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdlib.h>
#include <stdio.h>
#include "bstring.h"
int main(int argc, char** argv)
{
struct string args;
int i; int j; int k;
string_init(&args, 1, 1);
string_concatb(&args, "foo", 3);
string_concatb(&args, "b", 1);
printf("%d\n", args._u._s.length);
for (i = 0; i < argc; i++) string_concat(&args, *argv++);
puts(string_get(&args));
string_free(&args);
for (j = 1; j <= 3; j++) {
for (k = 1; k <= 200; k+=50) {
printf("Testing with isize=%d growby=%d\n", j, k);
string_init(&args, j, k);
for (i = 0; i < 100; i++) {
string_concat(&args, "test");
}
printf("100x test == %d len, %d size, %d grow\n", args._u._s.length,
args._u._s.size, args._u._s.growby);
string_free(&args);
}
}
return 0;
}