6 use Support::TestSetup;
 
   8 Support::TestSetup::login();
 
  13   is(Common::truncate('nothing to do', at => -1),  '...',           'truncation length < 0: at least 3');
 
  14   is(Common::truncate('nothing to do', at => 0),   '...',           'truncation length = 0: at least 3');
 
  15   is(Common::truncate('nothing to do', at => 1),   '...',           'truncation length = 1: at least 3');
 
  16   is(Common::truncate('nothing to do', at => 2),   '...',           'truncation length = 2: at least 3');
 
  17   is(Common::truncate('nothing to do', at => 3),   '...',           'truncation length = 3: at least 3');
 
  18   is(Common::truncate('nothing to do', at => 4),   'n...',          'truncation length = 4');
 
  19   is(Common::truncate('nothing to do', at => 9),   'nothin...',     'text length equal to truncation + 4');
 
  20   is(Common::truncate('nothing to do', at => 10),  'nothing...',    'text length equal to truncation + 3');
 
  21   is(Common::truncate('nothing to do', at => 11),  'nothing ...',   'text length equal to truncation + 2');
 
  22   is(Common::truncate('nothing to do', at => 12),  'nothing t...',  'text length equal to truncation + 1');
 
  23   is(Common::truncate('nothing to do', at => 13),  'nothing to do', 'text length equal to truncation');
 
  24   is(Common::truncate('nothing to do', at => 14),  'nothing to do', 'text length equal to truncation - 1');
 
  25   is(Common::truncate('nothing to do', at => 15),  'nothing to do', 'text length equal to truncation - 2');
 
  26   is(Common::truncate('nothing to do', at => 16),  'nothing to do', 'text length equal to truncation - 3');
 
  27   is(Common::truncate('nothing to do', at => 200), 'nothing to do', 'text length smaller than truncation');
 
  29   is(Common::truncate('012345678901234567890123456789012345678901234567890123456789'), '01234567890123456789012345678901234567890123456...', 'default truncation length of 50');
 
  32   is(Common::truncate("nothing\n\rat\rall\n\n", at => 50, strip => 1), "nothing\n\rat\rall", 'strip = 1, at = 50');
 
  33   is(Common::truncate("nothing\n\rat\rall\n\n", at => 13, strip => 1), "nothing\n\ra...",    'strip = 1, at = 13');
 
  35   is(Common::truncate("nothing\n\rat\rall\n\n", at => 50, strip => 'full'), "nothing at all", 'strip = full, at = 50');
 
  36   is(Common::truncate("nothing\n\rat\rall\n\n", at => 13, strip => 'full'), "nothing at...",  'strip = full, at = 13');
 
  38   is(Common::truncate("nothing\n\rat\rall\n\n", at => 50, strip => 'newlines'), "nothing at all", 'strip = newlines, at = 50');
 
  39   is(Common::truncate("nothing\n\rat\rall\n\n", at => 13, strip => 'newlines'), "nothing at...",  'strip = newlines, at = 13');
 
  41   is(Common::truncate("nothing\n\rat\rall\n\n", at => 50, strip => 'newline'), "nothing at all", 'strip = newline, at = 50');
 
  42   is(Common::truncate("nothing\n\rat\rall\n\n", at => 13, strip => 'newline'), "nothing at...",  'strip = newline, at = 13');