File: testarray.c

package info (click to toggle)
fcitx 1%3A4.2.9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,800 kB
  • sloc: ansic: 134,151; cpp: 7,280; sh: 2,778; python: 800; xml: 345; makefile: 42
file content (36 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (7)
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
#include <assert.h>
#include "fcitx-utils/utils.h"
#include "fcitx/fcitx.h"

int main()
{
    UT_array array;
    utarray_init(&array, &ut_int_icd);
    int test[] = {3, 1, 2};
    int test2[] = {1, 2, 3};
    FCITX_UNUSED(test);
    FCITX_UNUSED(test2);
    int i;
    i = 1;
    utarray_push_back(&array, &i);
    i = 2;
    utarray_push_back(&array, &i);
    i = 3;
    utarray_push_back(&array, &i);
    utarray_move(&array, 2, 0);
    {
        utarray_foreach(p, &array, int) {
            assert(*p == test[utarray_eltidx(&array, p)]);
        }
    }
    utarray_move(&array, 0, 2);

    {
        utarray_foreach(p, &array, int) {
            assert(*p == test2[utarray_eltidx(&array, p)]);
        }
    }
    utarray_done(&array);

    return 0;
}