File: test-mongoc-list.c

package info (click to toggle)
syslog-ng 3.8.1-10
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 47,320 kB
  • ctags: 43,937
  • sloc: ansic: 159,432; yacc: 25,059; sh: 13,574; makefile: 4,669; python: 3,468; java: 3,218; xml: 2,309; perl: 318; lex: 316; awk: 184
file content (53 lines) | stat: -rw-r--r-- 1,273 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <mongoc.h>
#include <mongoc-list-private.h>

#include "TestSuite.h"


static void
test_mongoc_list_basic (void)
{
   mongoc_list_t *l;

   l = _mongoc_list_append(NULL, (void *)1ULL);
   l = _mongoc_list_append(l, (void *)2ULL);
   l = _mongoc_list_append(l, (void *)3ULL);
   l = _mongoc_list_prepend(l, (void *)4ULL);

   ASSERT(l);
   ASSERT(l->next);
   ASSERT(l->next->next);
   ASSERT(l->next->next->next);
   ASSERT(!l->next->next->next->next);

   ASSERT(l->data == (void *)4ULL);
   ASSERT(l->next->data == (void *)1ULL);
   ASSERT(l->next->next->data == (void *)2ULL);
   ASSERT(l->next->next->next->data == (void *)3ULL);

   l = _mongoc_list_remove(l, (void *)4ULL);
   ASSERT(l->data == (void *)1ULL);
   ASSERT(l->next->data == (void *)2ULL);
   ASSERT(l->next->next->data == (void *)3ULL);

   l = _mongoc_list_remove(l, (void *)2ULL);
   ASSERT(l->data == (void *)1ULL);
   ASSERT(l->next->data == (void *)3ULL);
   ASSERT(!l->next->next);

   l = _mongoc_list_remove(l, (void *)1ULL);
   ASSERT(l->data == (void *)3ULL);
   ASSERT(!l->next);

   l = _mongoc_list_remove(l, (void *)3ULL);
   ASSERT(!l);

   _mongoc_list_destroy(l);
}


void
test_list_install (TestSuite *suite)
{
   TestSuite_Add (suite, "/List/Basic", test_mongoc_list_basic);
}