File: ends.t

package info (click to toggle)
libstring-truncate-perl 1.100570-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 124 kB
  • ctags: 10
  • sloc: perl: 277; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings;

use Test::More tests => 4;

BEGIN { use_ok('String::Truncate', qw(elide trunc)); }

my $brain = "this is your brain";

is(
  elide($brain, 16, { truncate => 'ends' }),
  "... is your b...",
  "elide both ends",
);

eval { elide($brain, 5, { truncate => 'ends' }) };
like($@, qr/longer/, "marker can't exceed 1/2 length for end elision");

is(
  elide("I will use short ones to get more.", 20,
    { truncate => 'ends', at_space => 1 }
  ),
  "...short ones to...",
  "at_space lets us break betwen words (elide, at ends)",
);