Merge in local trunk
[awesomized/libmemcached] / tests / parser.cc
index 118c5f934a69c3de45459a42bb5443f5b8d46446..68a65a40f011aaeab15e8e71da5601e8cfb298ec 100644 (file)
@@ -43,8 +43,8 @@
 #include <errno.h>
 
 #define BUILDING_LIBMEMCACHED
-#include <libmemcached/memcached.h>
-#include <libmemcached/memcached.h>
+// !NEVER use common.h, always use memcached.h in your own apps
+#include <libmemcached/common.h>
 
 #include "tests/parser.h"
 #include "tests/print.h"
@@ -240,7 +240,7 @@ static test_return_t _test_option(scanner_variable_t *scanner, bool test_true= t
   for (scanner_variable_t *ptr= scanner; ptr->type != NIL; ptr++)
   {
     memcached_st *memc;
-    memc= memcached_create_with_options(ptr->option.c_str, ptr->option.size);
+    memc= memcached(ptr->option.c_str, ptr->option.size);
     if (test_true)
     {
       if (not memc)
@@ -332,8 +332,9 @@ test_return_t memcached_create_with_options_with_filename(memcached_st*)
     return TEST_SKIPPED;
 
   memcached_st *memc_ptr;
-  memc_ptr= memcached_create_with_options(STRING_WITH_LEN("--CONFIGURE-FILE=\"support/example.cnf\""));
-  test_true_got(memc_ptr, memcached_last_error_message(memc_ptr));
+  memc_ptr= memcached(STRING_WITH_LEN("--CONFIGURE-FILE=\"support/example.cnf\""));
+  test_true_got(memc_ptr, "memcached() failed");
+  test_strcmp(SUPPORT_EXAMPLE_CNF, memcached_array_string(memc_ptr->configure.filename));
   memcached_free(memc_ptr);
 
   return TEST_SUCCESS;
@@ -348,13 +349,13 @@ test_return_t libmemcached_check_configuration_with_filename_test(memcached_st*)
   char buffer[BUFSIZ];
 
   rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=\"support/example.cnf\""), buffer, sizeof(buffer));
-  test_true_got(rc == MEMCACHED_SUCCESS, buffer);
+  test_true_got(rc == MEMCACHED_SUCCESS, (rc == MEMCACHED_ERRNO) ? strerror(errno) : memcached_strerror(NULL, rc));
 
   rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=support/example.cnf"), buffer, sizeof(buffer));
-  test_false_with(rc == MEMCACHED_SUCCESS, buffer);
+  test_false_with(rc == MEMCACHED_SUCCESS, memcached_strerror(NULL, rc));
 
   rc= libmemcached_check_configuration(STRING_WITH_LEN("--CONFIGURE-FILE=\"bad-path/example.cnf\""), buffer, sizeof(buffer));
-  test_true_got(rc == MEMCACHED_ERRNO, buffer);
+  test_true_got(rc == MEMCACHED_ERRNO, memcached_strerror(NULL, rc));
 
   return TEST_SUCCESS;
 }
@@ -377,11 +378,11 @@ test_return_t libmemcached_check_configuration_test(memcached_st*)
 test_return_t memcached_create_with_options_test(memcached_st*)
 {
   memcached_st *memc_ptr;
-  memc_ptr= memcached_create_with_options(STRING_WITH_LEN("--server=localhost"));
+  memc_ptr= memcached(STRING_WITH_LEN("--server=localhost"));
   test_true_got(memc_ptr, memcached_last_error_message(memc_ptr));
   memcached_free(memc_ptr);
 
-  memc_ptr= memcached_create_with_options(STRING_WITH_LEN("--dude=localhost"));
+  memc_ptr= memcached(STRING_WITH_LEN("--dude=localhost"));
   test_false_with(memc_ptr, memcached_last_error_message(memc_ptr));
 
   return TEST_SUCCESS;
@@ -464,8 +465,7 @@ test_return_t random_statement_build_test(memcached_st*)
       random_options+= " ";
     }
 
-    memcached_st *memc_ptr= memcached_create(NULL);
-    memc_ptr= memcached_create_with_options(random_options.c_str(), random_options.size() -1);
+    memcached_st *memc_ptr= memcached(random_options.c_str(), random_options.size() -1);
     if (not memc_ptr)
     {
       switch (errno)