File: test_buffer_undo.c

package info (click to toggle)
mle 1.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,108 kB
  • sloc: ansic: 13,335; sh: 728; php: 228; makefile: 83
file content (29 lines) | stat: -rw-r--r-- 755 bytes parent folder | download | duplicates (2)
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
#include "test.h"

char *str = "hi";

void test(buffer_t *buf, mark_t *cur) {
    char *data;
    bint_t data_len;
    int action_group;

    buffer_delete(buf, 0, 1);
    buffer_undo(buf);
    buffer_get(buf, &data, &data_len);
    ASSERT("del", 0, strncmp(data, "hi", data_len));

    buffer_insert(buf, 0, "c", 1, NULL);
    buffer_undo(buf);
    buffer_get(buf, &data, &data_len);
    ASSERT("ins", 0, strncmp(data, "hi", data_len));

    action_group = 0;
    buffer_set_action_group_ptr(buf, &action_group);

    buffer_insert(buf, 2, "t", 1, NULL);
    buffer_insert(buf, 3, "!", 1, NULL);
    action_group += 1;
    buffer_undo_action_group(buf);
    buffer_get(buf, &data, &data_len);
    ASSERT("ins_group", 0, strncmp(data, "hi", data_len));
}