1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
6{
7    package Stream::Buffered::Sub;
8    use base 'Stream::Buffered';
9}
10
11{
12    my $b = Stream::Buffered::Sub->new(-1);
13    $b->print("foo");
14    is $b->size, 3;
15    my $fh = $b->rewind;
16    is do { local $/; <$fh> }, 'foo';
17    $fh->seek(0, 0);
18}
19
20{
21    local $Stream::Buffered::MaxMemoryBufferSize = 12;
22    my $b = Stream::Buffered::Sub->new;
23    is $b->size, 0;
24    $b->print("foo") for 1..5;
25    is $b->size, 15;
26    my $fh = $b->rewind;
27    isa_ok $fh, 'IO::File';
28    is do { local $/; <$fh> }, ('foo' x 5);
29}
30
31{
32    local $Stream::Buffered::MaxMemoryBufferSize = 0;
33    my $b = Stream::Buffered::Sub->new(3);
34    $b->print("foo\n");
35    is $b->size, 4;
36    my $fh = $b->rewind;
37    isa_ok $fh, 'IO::File';
38    is do { local $/; <$fh> }, "foo\n";
39}
40
41done_testing;
42