summaryrefslogtreecommitdiff
path: root/tests/piece-table-insert.c
blob: 76044551936e6370ac410b6ee6c6c757bc95f038 (plain)
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
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include "../src/piece-table-internals.h"

int
main()
{
  piece_table *pt = piece_table_create_from_str ("0123456789", 10);
  char tmp[100];

  piece_table_insert (pt, 10, "abcdefgh", 8);
  piece_table_to_string (pt, tmp, 99);
  assert (0 == strcmp (tmp, "0123456789abcdefgh"));

  piece_table_insert (pt, 18, "abcdefgh", 8);
  piece_table_to_string (pt, tmp, 99);
  assert (0 == strcmp (tmp, "0123456789abcdefghabcdefgh"));

  piece_table_insert (pt, 4, "abcdefgh", 8);
  piece_table_to_string (pt, tmp, 99);
  assert (0 == strcmp (tmp, "0123abcdefgh456789abcdefghabcdefgh"));

  piece_table_destroy (pt);

  return 0;
}