Working on getting version patch working
[awesomized/libmemcached] / tests / function.c
index f52bf783e15f563da0f764d39f77996216bf6a5e..748eac57a76c726e1f604f94fd81385bd8a65eed 100644 (file)
@@ -881,7 +881,7 @@ uint8_t get_stats_keys(memcached_st *memc)
  list= memcached_stat_get_keys(memc, &stat, &rc);
  assert(rc == MEMCACHED_SUCCESS);
  for (ptr= list; *ptr; ptr++)
-   printf("Found key %s\n", *ptr);
+   assert(*ptr);
  fflush(stdout);
 
  free(list);
@@ -889,6 +889,14 @@ uint8_t get_stats_keys(memcached_st *memc)
  return 0;
 }
 
+uint8_t version_string_test
+{
+  const char *version_string;
+  version_string= memcached_lib_version();
+  assert(!strcmp(version_string, MEMCACHE_VERSION_STRING));
+  return 0;
+}
+
 uint8_t get_stats(memcached_st *memc)
 {
  unsigned int x;
@@ -949,6 +957,55 @@ uint8_t add_host_test(memcached_st *memc)
   return 0;
 }
 
+memcached_return clone_test_callback(memcached_st *parent, memcached_st *clone)
+{
+  return MEMCACHED_SUCCESS;
+}
+
+memcached_return cleanup_test_callback(memcached_st *ptr)
+{
+  return MEMCACHED_SUCCESS;
+}
+
+uint8_t callback_test(memcached_st *memc)
+{
+  /* Test User Data */
+  {
+    int x= 5;
+    int *test_ptr;
+    memcached_return rc;
+
+    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_USER_DATA, &x);
+    assert(rc == MEMCACHED_SUCCESS);
+    test_ptr= (int *)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc);
+    assert(*test_ptr == x);
+  }
+
+  /* Test Clone Callback */
+  {
+    clone_func temp_function;
+    memcached_return rc;
+
+    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, clone_test_callback);
+    assert(rc == MEMCACHED_SUCCESS);
+    temp_function= (clone_func)memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc);
+    assert(temp_function == clone_test_callback);
+  }
+
+  /* Test Cleanup Callback */
+  {
+    cleanup_func temp_function;
+    memcached_return rc;
+
+    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, cleanup_test_callback);
+    assert(rc == MEMCACHED_SUCCESS);
+    temp_function= (cleanup_func)memcached_callback_get(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, &rc);
+    assert(temp_function == cleanup_test_callback);
+  }
+
+  return 0;
+}
+
 /* We don't test the behavior itself, we test the switches */
 uint8_t behavior_test(memcached_st *memc)
 {
@@ -994,6 +1051,15 @@ uint8_t behavior_test(memcached_st *memc)
   value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
   assert(value > 0);
 
+  {
+    int x= 5;
+    int *test_ptr;
+
+    memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USER_DATA, &x);
+    test_ptr= (int *)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_USER_DATA);
+    assert(*test_ptr == x);
+  }
+
   return 0;
 }
 
@@ -2075,6 +2141,8 @@ test_st tests[] ={
   {"add_host_test", 0, add_host_test },
   {"get_stats_keys", 0, get_stats_keys },
   {"behavior_test", 0, get_stats_keys },
+  {"callback_test", 0, get_stats_keys },
+  {"version_string_test", 0, version_string_test},
   {0, 0, 0}
 };