5 #include <memcached.hh>
10 #include <sys/types.h>
18 uint8_t basic_test(memcached_st
*memc
)
21 char *value_set
= "This is some data";
25 foo
.set("mine", value_set
, strlen(value_set
));
26 value
= foo
.get("mine", &value_length
);
28 assert((memcmp(value
, value_set
, value_length
) == 0));
32 uint8_t basic_master_key_test(memcached_st
*memc
)
35 char *value_set
= "Data for server A";
36 char *master_key_a
= "server-a";
37 char *master_key_b
= "server-b";
42 foo
.set_by_key(master_key_a
, key
, value_set
, strlen(value_set
));
43 value
= foo
.get_by_key(master_key_a
, key
, &value_length
);
45 assert((memcmp(value
, value_set
, value_length
) == 0));
47 value
= foo
.get_by_key(master_key_b
, key
, &value_length
);
48 assert((memcmp(value
, value_set
, value_length
) == 0));
55 {"basic", 0, basic_test
},
56 {"basic_master_key", 0, basic_master_key_test
},
60 collection_st collection
[] ={
61 {"block", 0, 0, tests
},
65 #define SERVERS_TO_CREATE 1
67 void *world_create(void)
70 memcached_server_st
*servers
;
71 server_startup_st
*construct
;
73 construct
= (server_startup_st
*)malloc(sizeof(server_startup_st
));
74 memset(construct
, 0, sizeof(server_startup_st
));
76 construct
->count
= SERVERS_TO_CREATE
;
77 server_startup(construct
);
82 void world_destroy(void *p
)
84 server_startup_st
*construct
= (server_startup_st
*)p
;
85 memcached_server_st
*servers
= (memcached_server_st
*)construct
->servers
;
86 memcached_server_list_free(servers
);
88 server_shutdown(construct
);
92 void get_world(world_st
*world
)
94 world
->collections
= collection
;
95 world
->create
= world_create
;
96 world
->destroy
= world_destroy
;