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
34
35
36
37
|
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "../src/piece-table-internals.h"
int
main ()
{
piece_table *pt = piece_table_create_from_str ("0123456789", 10);
char tmp[100];
piece_table_delete (pt, 0, 10);
piece_table_to_string (pt, tmp, 99);
assert (0 == strcmp (tmp, ""));
piece_table_destroy (pt);
pt = piece_table_create_from_str ("0123456789", 10);
piece_table_delete (pt, 0, 1);
piece_table_to_string (pt, tmp, 99);
assert (0 == strcmp (tmp, "123456789"));
piece_table_destroy (pt);
pt = piece_table_create_from_str ("0123456789", 10);
piece_table_delete (pt, 9, 1);
piece_table_to_string (pt, tmp, 99);
assert (0 == strcmp (tmp, "012345678"));
piece_table_destroy (pt);
pt = piece_table_create_from_str ("0123456789", 10);
piece_table_delete (pt, 7, 1);
piece_table_delete (pt, 0, 1);
piece_table_to_string (pt, tmp, 99);
assert (0 == strcmp (tmp, "12345689"));
piece_table_destroy (pt);
return 0;
}
|