tests/mem_functions.cc
/*
  Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist.
*/
Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist.
Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist .
static test_return_t user_supplied_bug12(memcached_st *memc)
{
  memcached_return_t rc;
  uint32_t flags;
  size_t value_length;
  char *value;
  uint64_t number_value;
  value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
                        &value_length, &flags, &rc);
  test_true(value == NULL);
  test_compare(MEMCACHED_NOTFOUND, rc);
  rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"),
                          1, &number_value);
  test_true(value == NULL);
  if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1)
  {
    test_compare(MEMCACHED_SUCCESS, rc);
  }
  else
  {
    test_compare(MEMCACHED_NOTFOUND, rc);
  }
  rc= memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0);
  value= memcached_get(memc, "autoincrement", strlen("autoincrement"),
                        &value_length, &flags, &rc);
  test_true(value);
  test_compare(MEMCACHED_SUCCESS, rc);
  free(value);
  rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"),
                          1, &number_value);
  test_true(number_value == 2);
  test_compare(MEMCACHED_SUCCESS, rc);
  return TEST_SUCCESS;
}
static test_return_t user_supplied_bug12 ( memcached_st * memc ) { memcached_return_t rc ; uint32_t flags ; size_t value_length ; char * value ; uint64_t number_value ; value = memcached_get ( memc , " " , strlen ( " " ) , & value_length , & flags , & rc ) ; test_true ( value == NULL ) ; test_compare ( MEMCACHED_NOTFOUND , rc ) ; rc = memcached_increment ( memc , " " , strlen ( " " ) , 1 , & number_value ) ; test_true ( value == NULL ) ; if ( memcached_behavior_get ( memc , MEMCACHED_BEHAVIOR_BINARY_PROTOCOL ) == 1 ) { test_compare ( MEMCACHED_SUCCESS , rc ) ; } else { test_compare ( MEMCACHED_NOTFOUND , rc ) ; } rc = memcached_set ( memc , " " , strlen ( " " ) , " " , 1 , 0 , 0 ) ; value = memcached_get ( memc , " " , strlen ( " " ) , & value_length , & flags , & rc ) ; test_true ( value ) ; test_compare ( MEMCACHED_SUCCESS , rc ) ; free ( value ) ; rc = memcached_increment ( memc , " " , strlen ( " " ) , 1 , & number_value ) ; test_true ( number_value == 2 ) ; test_compare ( MEMCACHED_SUCCESS , rc ) ; return TEST_SUCCESS ; }
Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist.
Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist .
/* The binary protocol will set the key if it doesn't exist */