Code

Use tokkee's tag name scheme.
[pkg-collectd.git] / contrib / collection3 / test.px
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use HTML::Entities;
7 use Carp ('croak');
9 my @bad_strings = ("foo\x0f<bar>\n", "foo\x00<bar>\n");
10 my @good_strings = ("foo <bar>\n", "foo\t<bar>\n");
12 sub contains_invalid_chars
13 {
14   my $str = shift;
16   for (split (m//, $str))
17   {
18     my $n = ord ($_);
20     if (($n >= 9) && ($n <= 13))
21     {
22       next;
23     }
24     elsif ($n < 32)
25     {
26       return (1);
27     }
28   }
30   return;
31 }
33 sub assert
34 {
35   if (!$_[0])
36   {
37     croak ("assertion failed");
38   }
39 }
41 for (@bad_strings)
42 {
43   assert (contains_invalid_chars ($_));
44 }
46 for (@good_strings)
47 {
48   assert (!contains_invalid_chars ($_));
49 }