Skip to content

Commit

Permalink
Test for binary set/add returning CAS value.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Sep 2, 2009
1 parent c6f2087 commit f9bc2b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions t/binary.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
use Test::More tests => 3313;
use Test::More tests => 3315;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
Expand Down Expand Up @@ -212,21 +212,23 @@ is($mc->decr("x", 211), 0, "Floor is zero");
ok($@->not_found, "Error was 'not found' as expected");
}

$mc->add("x", "original value", 5, 19);
my ($r, $rcas) = $mc->add("x", "original value", 5, 19);

my ($flags, $val, $i) = $mc->get("x");
is($val, "original value", "->gets returned proper value");
is($rcas, $i, "Add CAS matched.");

{
my $rv =()= eval { $mc->set("x", "broken value", 19, 5, $i+1) };
is($rv, 0, "Empty return on expected failure (1)");
ok($@->exists, "Expected error state of 'exists' (1)");
}

$mc->set("x", "new value", 19, 5, $i);
$r, $rcas = $mc->set("x", "new value", 19, 5, $i);

my ($newflags, $newval, $newi) = $mc->get("x");
is($newval, "new value", "CAS properly overwrote value");
is($rcas, $newi, "Get CAS matched.");

{
my $rv =()= eval { $mc->set("x", "replay value", 19, 5, $i) };
Expand Down

0 comments on commit f9bc2b1

Please sign in to comment.