aboutsummaryrefslogtreecommitdiff
path: root/src/service/reclaim/test_reclaim_attribute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/reclaim/test_reclaim_attribute.c')
-rw-r--r--src/service/reclaim/test_reclaim_attribute.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/service/reclaim/test_reclaim_attribute.c b/src/service/reclaim/test_reclaim_attribute.c
new file mode 100644
index 000000000..acbcda62d
--- /dev/null
+++ b/src/service/reclaim/test_reclaim_attribute.c
@@ -0,0 +1,49 @@
1#include "platform.h"
2#include "gnunet_common.h"
3#include "gnunet_reclaim_lib.h"
4
5int
6main (int argc, char *argv[])
7{
8 struct GNUNET_RECLAIM_AttributeList *al;
9 struct GNUNET_RECLAIM_AttributeList *al_two;
10 struct GNUNET_RECLAIM_AttributeListEntry *ale;
11 char attrname[100];
12 char attrdata[100];
13 size_t ser_len_claimed;
14 size_t ser_len_actual;
15 char *ser_data;
16 int count = 0;
17
18 al = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
19 for (int i = 0; i < 12; i++)
20 {
21 memset (attrname, 0, 100);
22 memset (attrdata, 0, 100);
23 sprintf (attrname, "attr%d", i);
24 sprintf (attrdata, "%d", i);
25 ale = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
26 ale->attribute = GNUNET_RECLAIM_attribute_new (attrname,
27 &GNUNET_RECLAIM_ID_ZERO,
28 GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,
29 attrdata,
30 strlen (attrdata));
31 GNUNET_CONTAINER_DLL_insert (al->list_head,
32 al->list_tail,
33 ale);
34 }
35 ser_len_claimed = GNUNET_RECLAIM_attribute_list_serialize_get_size (al);
36 ser_data = GNUNET_malloc (ser_len_claimed);
37 ser_len_actual = GNUNET_RECLAIM_attribute_list_serialize (al,
38 ser_data);
39 GNUNET_assert (ser_len_claimed == ser_len_actual);
40 al_two = GNUNET_RECLAIM_attribute_list_deserialize (ser_data,
41 ser_len_actual);
42 for (ale = al_two->list_head; NULL != ale; ale = ale->next)
43 count++;
44 GNUNET_assert (12 == count);
45 //GNUNET_assert (-1 != deser_len);
46 GNUNET_free (ser_data);
47 GNUNET_RECLAIM_attribute_list_destroy (al);
48 GNUNET_RECLAIM_attribute_list_destroy (al_two);
49}