testing: parser
[awesomized/libmemcached] / tests / libmemcached-1.0 / touch.cc
index 50e6a3599b0924ab4896af582d5aa2a55cdd2fd1..5f894339dd24600eddb01688fe1944144ad97370 100644 (file)
  *
  */
 
-#include <config.h>
-#include <libtest/test.hpp>
+#include "mem_config.h"
+#include "libtest/test.hpp"
 
 using namespace libtest;
 
-#include <libmemcached-1.0/memcached.h>
-#include <libmemcachedutil-1.0/util.h>
+#include "libmemcached-1.0/memcached.h"
+#include "libmemcachedutil-1.0/util.h"
 
 #include "tests/touch.h"
 
 static test_return_t pre_touch(memcached_st *memc)
 {
   test_compare(MEMCACHED_SUCCESS, memcached_version(memc));
-  test_skip(true, libmemcached_util_version_check(memc, 1, 4, 8));
+  test_skip(true, libmemcached_util_version_check(memc, 1, 4, 15));
 
   return TEST_SUCCESS;
 }
 
 test_return_t test_memcached_touch(memcached_st *memc)
 {
-
   test_skip(TEST_SUCCESS, pre_touch(memc));
 
   size_t len;
@@ -63,20 +62,20 @@ test_return_t test_memcached_touch(memcached_st *memc)
   memcached_return rc;
 
   test_null(memcached_get(memc, 
-                          test_literal_param("touchkey"),
+                          test_literal_param(__func__),
                           &len, &flags, &rc));
   test_zero(len);
   test_compare(MEMCACHED_NOTFOUND, rc);
 
   test_compare(MEMCACHED_SUCCESS, 
                memcached_set(memc,
-                             test_literal_param("touchkey"),
+                             test_literal_param(__func__),
                              test_literal_param("touchval"),
                              2, 0));
 
   {
     char *value= memcached_get(memc, 
-                               test_literal_param("touchkey"),
+                               test_literal_param(__func__),
                                &len, &flags, &rc);
     test_compare(8U, test_literal_param_size("touchval"));
     test_true(value);
@@ -85,23 +84,20 @@ test_return_t test_memcached_touch(memcached_st *memc)
     free(value);
   }
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_touch(memc, test_literal_param("touchkey"), 60 *60));
-
-  test_skip(false ,memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+  rc= memcached_touch(memc, test_literal_param(__func__), 60 *60);
+  ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
 
-  rc= memcached_touch(memc, test_literal_param("touchkey"), 60 *60 *24 *60);
-  test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc));
+  rc= memcached_touch(memc, test_literal_param(__func__), 60 *60 *24 *60);
+  ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
 
-  test_compare(MEMCACHED_NOTFOUND,
-               memcached_exist(memc, test_literal_param("touchkey")));
+  rc= memcached_exist(memc, test_literal_param(__func__));
+  ASSERT_EQ_(MEMCACHED_NOTFOUND, rc, "%s", memcached_last_error_message(memc));
 
   return TEST_SUCCESS;
 }
 
 test_return_t test_memcached_touch_by_key(memcached_st *memc)
 {
-
   test_skip(TEST_SUCCESS, pre_touch(memc));
 
   size_t len;
@@ -110,7 +106,7 @@ test_return_t test_memcached_touch_by_key(memcached_st *memc)
 
   test_null(memcached_get_by_key(memc, 
                                  test_literal_param("grouping_key"),
-                                 test_literal_param("touchkey"),
+                                 test_literal_param(__func__),
                                  &len, &flags, &rc));
   test_zero(len);
   test_compare(MEMCACHED_NOTFOUND, rc);
@@ -118,14 +114,14 @@ test_return_t test_memcached_touch_by_key(memcached_st *memc)
   test_compare(MEMCACHED_SUCCESS, 
                memcached_set_by_key(memc,
                                     test_literal_param("grouping_key"),
-                                    test_literal_param("touchkey"),
+                                    test_literal_param(__func__),
                                     test_literal_param("touchval"),
                                     2, 0));
 
   {
     char *value= memcached_get_by_key(memc, 
                                       test_literal_param("grouping_key"),
-                                      test_literal_param("touchkey"),
+                                      test_literal_param(__func__),
                                       &len, &flags, &rc);
     test_compare(8U, test_literal_param_size("touchval"));
     test_true(value);
@@ -134,20 +130,20 @@ test_return_t test_memcached_touch_by_key(memcached_st *memc)
     free(value);
   }
 
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_touch_by_key(memc,
-                                      test_literal_param("grouping_key"),
-                                      test_literal_param("touchkey"),
-                                      60 *60));
+  rc= memcached_touch_by_key(memc,
+                             test_literal_param("grouping_key"),
+                             test_literal_param(__func__),
+                             60 *60);
+  ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
 
-  test_skip(false ,memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-  test_compare(MEMCACHED_SUCCESS,
-               memcached_touch_by_key(memc,
-                                      test_literal_param("grouping_key"),
-                                      test_literal_param("touchkey"),
-                                      60 *60 *24 *60));
-  test_compare(MEMCACHED_NOTFOUND,
-               memcached_exist_by_key(memc, test_literal_param("grouping_key"),test_literal_param("touchkey")));
+  rc= memcached_touch_by_key(memc,
+                             test_literal_param("grouping_key"),
+                             test_literal_param(__func__),
+                             60 *60 *24 *60);
+  ASSERT_EQ_(MEMCACHED_SUCCESS, rc, "%s", memcached_last_error_message(memc));
+
+  rc= memcached_exist_by_key(memc, test_literal_param("grouping_key"),test_literal_param(__func__));
+  ASSERT_EQ_(MEMCACHED_NOTFOUND, rc, "%s", memcached_last_error_message(memc));
 
   return TEST_SUCCESS;
 }