File: 03response-error.t

package info (click to toggle)
libhttp-parser-xs-perl 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 452 kB
  • sloc: perl: 1,881; ansic: 926; makefile: 13
file content (59 lines) | stat: -rw-r--r-- 796 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;
use warnings;
use Test::More;
use HTTP::Parser::XS qw/:all/;

use Data::Dumper;

my $tests = <<'__HEADERS';
HOGE

----------
-1
----------
HTTP/1.0 200 OK
----------
-2
----------
HTTP/1.0 200 OK
Content-Type: text/html
X-Test: 1
X-Test: 2

hogehoge
----------
61
----------
HTTP/1.0 200 OK
Content-Type: text/html
X-Test: 1
 X-Test: 2

hogehoge
----------
62
----------
HTTP/1.0 200 OK
Content-Type: text/html
----------
-2
__HEADERS



my @tests = split '-'x10, $tests;
my $i = 0;
while (@tests) {
    $i++;
    my $header = shift @tests;
    my $expect = shift @tests;
    $header =~ s/^\n//;
    last unless $expect;
    my $res  = [];
    my ($ret) = parse_http_response($header, HEADERS_AS_HASHREF);
    my $r    = eval($expect);
    is( $ret, $r, "test-$i");
}

done_testing;