File: 04-strerror.t

package info (click to toggle)
libmemcached-libmemcached-perl 1.001801%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 912 kB
  • ctags: 773
  • sloc: perl: 1,674; makefile: 25
file content (43 lines) | stat: -rw-r--r-- 1,077 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43

# tests for functions documented in memcached_strerror.pod

use strict;
use warnings;

use Test::More;

use Memcached::libmemcached
    #   functions explicitly tested by this file
    qw(
        memcached_strerror
        memcached_errstr
    ),
    #   other functions used by the tests
    qw(
        memcached_server_add_unix_socket
        MEMCACHED_INVALID_ARGUMENTS
    );

use lib 't/lib';
use libmemcached_test;

my $memc = libmemcached_test_create();

plan tests => 6;
$| = 1;

is memcached_strerror($memc, 0), 'SUCCESS';
is memcached_strerror($memc, 1), 'FAILURE';

# XXX also test dual-var nature of return codes here
my $rc = memcached_server_add_unix_socket($memc, undef); # should fail
is $rc, undef, 'rc should not be defined';

my $errstr = $memc->errstr;
#use Devel::Peek; Dump($errstr);
cmp_ok $errstr, '==', MEMCACHED_INVALID_ARGUMENTS(),
    'should be MEMCACHED_INVALID_ARGUMENTS integer in numeric context';
cmp_ok $errstr, 'eq', "INVALID ARGUMENTS",
    'should be "INVALID ARGUMENTS" string in string context';

is $errstr, memcached_errstr($memc);