File: 18_incr_decr.t

package info (click to toggle)
libcache-memcached-libmemcached-perl 0.04001-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 340 kB
  • sloc: perl: 2,274; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use lib 't/lib';
use libmemcached_test;
use Test::More;

my $cache = libmemcached_test_create( {
    namespace => join('_', 'Cache::Memcached::libmemcached', 'test', rand(), $$)
} );

plan(tests => 5);

isa_ok($cache, "Cache::Memcached::libmemcached");

{
    my $key = 'foo';

    {
        $cache->set($key, 0);
        is( $cache->get($key), 0, "value is 0 initially");
    }

    {
        my $rv = $cache->incr($key);
        is( $rv, 1, "return value is $rv");
    }

    {
        my $rv = $cache->incr($key);
        is( $rv, 2, "return value is $rv");
    }

    {
        my $rv = $cache->decr($key);
        is( $rv, 1, "return value is $rv");
    }
}