Util.t 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More qw{no_plan};
  5. main();
  6. sub main {
  7. use_ok('Fcm::Util');
  8. test_tidy_url();
  9. }
  10. ################################################################################
  11. # Tests tidy_url
  12. sub test_tidy_url {
  13. my $prefix = "tidy_url";
  14. my %RESULT_OF = (
  15. '' => '',
  16. 'foo' => 'foo',
  17. 'foo/bar' => 'foo/bar',
  18. 'http://foo/bar' => 'http://foo/bar',
  19. 'http://foo/bar@1234' => 'http://foo/bar@1234',
  20. 'http://foo/bar/@1234' => 'http://foo/bar@1234',
  21. 'http://foo/bar/.' => 'http://foo/bar',
  22. 'http://foo/bar/.@1234' => 'http://foo/bar@1234',
  23. 'http://foo/bar/./@1234' => 'http://foo/bar@1234',
  24. 'http://foo/bar/./baz' => 'http://foo/bar/baz',
  25. 'http://foo/bar/..' => 'http://foo',
  26. 'http://foo/bar/..@1234' => 'http://foo@1234',
  27. 'http://foo/bar/../@1234' => 'http://foo@1234',
  28. 'http://foo/bar/../baz' => 'http://foo/baz',
  29. 'http://foo/bar/../.' => 'http://foo',
  30. 'http://foo/bar/baz/../..' => 'http://foo',
  31. );
  32. for my $key (sort keys(%RESULT_OF)) {
  33. is(tidy_url($key), $RESULT_OF{$key}, "$prefix: $key");
  34. }
  35. }
  36. # TODO: more unit tests
  37. __END__