summaryrefslogtreecommitdiff
path: root/tests/piece-table-delete.c
blob: c883b34839e350a5af869acafcde08562baa85ed (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
28
29
30
31
32
33
34
#include <stdio.h>
#include <string.h>
#include "../src/piece-table.h"

int
main()
{
  piece_table *pt = piece_table_create("0123456789");
  piece_table_delete(pt, 0, 10);
  if (strcmp(piece_table_to_string(pt), ""))
    return 1;
  piece_table_destroy(pt);

  pt = piece_table_create("0123456789");
  piece_table_delete(pt, 0, 1);
  if (strcmp(piece_table_to_string(pt), "123456789"))
    return 2;
  piece_table_destroy(pt);

  pt = piece_table_create("0123456789");
  piece_table_delete(pt, 9, 1);
  if (strcmp(piece_table_to_string(pt), "012345678"))
    return 3;
  piece_table_destroy(pt);

  pt = piece_table_create("0123456789");
  piece_table_delete(pt, 7, 1);
  piece_table_delete(pt, 0, 1);
  if (strcmp(piece_table_to_string(pt), "12345689"))
    return 4;
  piece_table_destroy(pt);

  return 0;
}