4 # error I depend on config.h
22 char message1
[] = "Buuh";
23 char message2
[] = "Baa";
25 larray_create (&array
);
26 assert(larray_buffersize(&array
) == 1);
27 larray_insert (&array
, message1
);
28 larray_insert (&array
, message2
);
29 assert (larray_get (&array
, 0) == message1
);
30 assert (larray_get (&array
, 1) == message2
);
32 assert (larray_contains (&array
, message1
) == TRUE
);
33 assert (larray_contains (&array
, message2
) == TRUE
);
34 assert (larray_size (&array
) == 2);
35 assert(larray_buffersize(&array
) == 11);
37 assert (larray_contains(&array
, message1
) == TRUE
);
38 larray_remove (&array
, message1
);
39 assert (larray_contains(&array
, message1
) == FALSE
);
40 assert (larray_get (&array
, 0) == message2
);
41 assert (larray_size(&array
) == 1);
43 assert (larray_size(&array
) == 0);
44 larray_destroy (&array
);
48 char message1
[] = "Buuh";
49 char message2
[] = "Baa";
54 lqueue_push (&q
, message1
);
55 lqueue_push (&q
, message2
);
57 assert (lqueue_empty(&q
) == FALSE
);
58 assert (lqueue_pop (&q
) == message1
);
59 assert (lqueue_pop (&q
) == message2
);
60 assert (lqueue_empty(&q
) == TRUE
);
61 assert (lqueue_pop (&q
) == NULL
);
68 for(i
= 0;i
< 20;i
++) {
69 printf("%d ",(int)(lrandom() % 100));
75 struct test_object_t
{
81 void destroy_test_object(struct test_object_t
*obj
) {
88 struct test_object_t
*obj
= lobject_create(struct test_object_t
);
91 lobject_set_destructor(obj
, (lobject_destructor
)&destroy_test_object
);
94 assert(test_val
== 0);
96 assert(test_val
== 1);
105 socket_writer(lsocket_provider_t
*p
,
116 socket_reader(lsocket_provider_t
*p
,
126 BOOL
poll(lsocket_provider_t
*p
,
134 struct lsocket_provider_funcs funcs
;
141 struct lsocket_provider
*provider
=
142 lsocket_create_provider(NULL
);
143 assert(provider
== NULL
);
145 funcs
.write_to_socket
= socket_writer
;
146 funcs
.read_from_socket
= socket_reader
;
149 provider
= lsocket_create_provider(&funcs
);
150 provider
->ptr
= NULL
;
153 struct lsocket
*sock
= lsocket_create(0,0);
154 assert(sock
!= NULL
);
156 assert(socket_write(sock
,NULL
,0) < 0);
158 assert(socket_read(sock
,NULL
,0) < 0);
161 lsocket_provider_connect_socket(provider
,sock
);
163 assert(socket_write(sock
,NULL
,0) == 0);
165 assert(socket_read(sock
,NULL
,0) == 0);
174 main (int argc
, char *argv
)