File: Cache-Memcached-GetParserXS.t

package info (click to toggle)
libcache-memcached-getparserxs-perl 0.01-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 127; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 644 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
#!/usr/bi/perl

use Test::More tests => 6;
BEGIN { use_ok('Cache::Memcached::GetParserXS') };
use Data::Dumper;

my $fin;
my $p = new_parser();
ok($p, "Parser object was created");

# simple case
$p->t_parse_buf("VALUE foo 0 3
bar
END
");
is_deeply($fin, { foo => 0 }, "got foo");

# in chunks...
$p = new_parser();
$p->t_parse_buf("VALUE foo 0 3
bar
VALUE bar 1 3
baz
");
is($fin, undef, "nothing yet");
$p->t_parse_buf("END");
is($fin, undef, "nothing yet");
$p->t_parse_buf("\n");
is_deeply($fin, { foo => 0, bar => 1 }, "got 'em");


sub new_parser {
    $fin = undef;
    Cache::Memcached::GetParserXS->new({}, 0, sub { $fin = $_[0] });
}