use strict;
use lib qw(lib ../lib);
use Template::Test;
use Template::Plugin::TruncateByWord;

test_expect(\*DATA);


__DATA__

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% 'abcdefg' | truncate_by_word(4) %]
-- expect --
abcd

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% '광고프로그램' | truncate_by_word(3) %]
-- expect --
광고프

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% '광고a프로b그램cdefg' | truncate_by_word(3) %]
-- expect --
광고a

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% '광고a프로b그램cdefg' | truncate_by_word %]
-- expect --
광고a프로b그램cdefg

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% '광고a프로b그램cdefg' | truncate_by_word(5,'...') %]
-- expect --
광고a프로...

-- test --
[% USE TruncateByWord 'euc-kr' -%]
[% '광고a프로b그램cdefg' | truncate_by_word(36,'...') %]
-- expect --
광고a프로b그램cdefg

-- test --
[% USE TruncateByWord('euc-kr', name='my_truncate') -%]
[% '광고a프로b그램cdefg' | my_truncate(3) %]
-- expect --
광고a

-- test --
[% USE TruncateByWord 'euc-kr' name='my_truncate' -%]
[% FILTER my_truncate(5,'..') -%]
광고a프로b그램cdefg
[% END %]
-- expect --
광고a프로..

-- test --
[% USE TruncateByWord enc='euc-kr' name='my_truncate' -%]
[% FILTER my_truncate(5,'..') -%]
광고a프로b그램cdefg
[% END %]
-- expect --
광고a프로..
