~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to winpr/libwinpr/utils/test/TestArrayList.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.1.9) (9.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20141111122050-wyr8hrnwco9fcmum
Tags: 1.1.0~git20140921.1.440916e+dfsg1-2ubuntu1
* Merge with Debian unstable, remaining changes
  - Disable ffmpeg support
* Disable gstreamer support, this relies on gstreamer 0.10 and we don't want
  to add any more deps on that.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include <winpr/crt.h>
 
3
#include <winpr/tchar.h>
 
4
#include <winpr/collections.h>
 
5
 
 
6
int TestArrayList(int argc, char* argv[])
 
7
{
 
8
        int index;
 
9
        int count;
 
10
        size_t val;
 
11
        wArrayList* arrayList;
 
12
        const int elemsToInsert = 10;
 
13
 
 
14
        arrayList = ArrayList_New(TRUE);
 
15
 
 
16
        for (index = 0; index < elemsToInsert; index++)
 
17
        {
 
18
                ArrayList_Add(arrayList, (void*) (size_t) index);
 
19
        }
 
20
 
 
21
        count = ArrayList_Count(arrayList);
 
22
 
 
23
        printf("ArrayList count: %d\n", count);
 
24
 
 
25
        index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
 
26
 
 
27
        printf("ArrayList index: %d\n", index);
 
28
 
 
29
        if (index != 6)
 
30
                return -1;
 
31
 
 
32
        ArrayList_Insert(arrayList, 5, (void*) (size_t) 100);
 
33
 
 
34
        index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
 
35
        printf("ArrayList index: %d\n", index);
 
36
 
 
37
        if (index != 7)
 
38
                return -1;
 
39
 
 
40
        ArrayList_Remove(arrayList, (void*) (size_t) 100);
 
41
 
 
42
        index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
 
43
        printf("ArrayList index: %d\n", index);
 
44
 
 
45
        if (index != 6)
 
46
                return -1;
 
47
 
 
48
        for (index = 0; index < elemsToInsert; index++) {
 
49
                val = (size_t)ArrayList_GetItem(arrayList, 0);
 
50
                ArrayList_RemoveAt(arrayList, 0);
 
51
                if (val != index)
 
52
                {
 
53
                        printf("ArrayList: shifted %d entries, expected value %d, got %ld\n", index, index, (long int)val);
 
54
                        return -1;
 
55
                }
 
56
        }
 
57
 
 
58
        index = ArrayList_IndexOf(arrayList, (void*) (size_t) elemsToInsert, -1, -1);
 
59
        printf("ArrayList index: %d\n", index);
 
60
        if (index != -1)
 
61
                return -1;
 
62
 
 
63
        count = ArrayList_Count(arrayList);
 
64
        printf("ArrayList count: %d\n", count);
 
65
        if (count != 0)
 
66
                return -1;
 
67
 
 
68
        ArrayList_Clear(arrayList);
 
69
        ArrayList_Free(arrayList);
 
70
 
 
71
        return 0;
 
72
}