20a537b1ac20ed28e7c7102dd666aa889cb7de55
5 #include <memcached.hh>
10 #include <sys/types.h>
18 test_return
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));
33 test_return
basic_master_key_test(memcached_st
*memc
)
36 char *value_set
= "Data for server A";
37 char *master_key_a
= "server-a";
38 char *master_key_b
= "server-b";
43 foo
.set_by_key(master_key_a
, key
, value_set
, strlen(value_set
));
44 value
= foo
.get_by_key(master_key_a
, key
, &value_length
);
46 assert((memcmp(value
, value_set
, value_length
) == 0));
48 value
= foo
.get_by_key(master_key_b
, key
, &value_length
);
49 assert((memcmp(value
, value_set
, value_length
) == 0));
56 {"basic", 0, basic_test
},
57 {"basic_master_key", 0, basic_master_key_test
},
61 collection_st collection
[] ={
62 {"block", 0, 0, tests
},
66 #define SERVERS_TO_CREATE 1
68 void *world_create(void)
71 memcached_server_st
*servers
;
72 server_startup_st
*construct
;
74 construct
= (server_startup_st
*)malloc(sizeof(server_startup_st
));
75 memset(construct
, 0, sizeof(server_startup_st
));
77 construct
->count
= SERVERS_TO_CREATE
;
78 server_startup(construct
);
83 void world_destroy(void *p
)
85 server_startup_st
*construct
= (server_startup_st
*)p
;
86 memcached_server_st
*servers
= (memcached_server_st
*)construct
->servers
;
87 memcached_server_list_free(servers
);
89 server_shutdown(construct
);
93 void get_world(world_st
*world
)
95 world
->collections
= collection
;
96 world
->create
= world_create
;
97 world
->destroy
= world_destroy
;