This adds a couple of new options for options parsing.
[m6w6/libmemcached] / tests / parser.cc
index 9eb8171494b4037d58c8ad6cc2e692dff1e47507..5a8187552638b1d35b2c25311d2372ed3abb0e02 100644 (file)
@@ -332,3 +332,49 @@ test_return_t parser_key_prefix_test(memcached_st *junk)
   (void)junk;
   return _test_option(distribution_strings);
 }
+
+test_return_t memcached_parse_file_options_test(memcached_st *junk)
+{
+  (void)junk;
+  memcached_st memc;
+  memcached_st *memc_ptr= memcached_create(&memc);
+
+  test_true(memc_ptr);
+
+  memcached_return_t rc= memcached_parse_file_options(memc_ptr, "support/example.cnf");
+  test_true_got(rc == MEMCACHED_SUCCESS, rc == MEMCACHED_INVALID_ARGUMENTS ? memcached_last_error_message(&memc) : memcached_strerror(NULL, rc));
+  memcached_free(memc_ptr);
+
+  return TEST_SUCCESS;
+}
+
+test_return_t memcached_check_options_test(memcached_st *junk)
+{
+  (void)junk;
+
+  memcached_return_t rc;
+
+  rc= memcached_check_options(STRING_WITH_LEN("--server=localhost"), NULL, 0);
+  test_true(rc == MEMCACHED_SUCCESS);
+
+  rc= memcached_check_options(STRING_WITH_LEN("--dude=localhost"), NULL, 0);
+  test_false(rc == MEMCACHED_SUCCESS);
+  test_true(rc == MEMCACHED_PARSE_ERROR);
+
+  return TEST_SUCCESS;
+}
+
+test_return_t memcached_create_with_options_test(memcached_st *junk)
+{
+  (void)junk;
+
+  memcached_st *memc_ptr;
+  memc_ptr= memcached_create_with_options(STRING_WITH_LEN("--server=localhost"));
+  test_true(memc_ptr);
+  memcached_free(memc_ptr);
+
+  memc_ptr= memcached_create_with_options(STRING_WITH_LEN("--dude=localhost"));
+  test_false(memc_ptr);
+
+  return TEST_SUCCESS;
+}