mconnect - KDE Connect protocol implementation in Vala/C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

  1. void test_find_urls_simple () {
  2. var urls = Utils.find_urls ("https://en.m.wikipedia.org/wiki/Isle_of_Man via DuckDuckGo for Android");
  3. assert (urls != null);
  4. assert (urls.length == 1);
  5. assert (urls[0] == "https://en.m.wikipedia.org/wiki/Isle_of_Man");
  6. }
  7. void test_find_urls_extract () {
  8. var urls = Utils.find_urls ("Foo bar baz?\n\nhttp://foo.bar.com/123/345/abcd\n\nShared from my Google cards");
  9. assert (urls != null);
  10. assert (urls.length == 1);
  11. assert (urls[0] == "http://foo.bar.com/123/345/abcd");
  12. }
  13. void test_find_urls_many () {
  14. var urls = Utils.find_urls ("https://foo.bar.com http://google.biz http://www.funny.io");
  15. assert (urls != null);
  16. assert (urls.length == 3);
  17. assert (urls[0] == "https://foo.bar.com");
  18. assert (urls[1] == "http://google.biz");
  19. assert (urls[2] == "http://www.funny.io");
  20. }
  21. void test_find_urls_none () {
  22. var urls = Utils.find_urls ("baz bar \nbar.com foo ");
  23. assert (urls != null);
  24. assert (urls.length == 0);
  25. }
  26. void test_find_urls_special () {
  27. var urls = Utils.find_urls ("http://foo.bar.com/123,345%20,,,/foo.html");
  28. assert (urls != null);
  29. assert (urls.length == 1);
  30. assert (urls[0] == "http://foo.bar.com/123,345%20,,,/foo.html");
  31. }
  32. public static void main (string[] args) {
  33. Test.init (ref args);
  34. Test.add_func ("/mconn-utils/find-urls/simple", test_find_urls_simple);
  35. Test.add_func ("/mconn-utils/find-urls/extract", test_find_urls_extract);
  36. Test.add_func ("/mconn-utils/find-urls/many", test_find_urls_many);
  37. Test.add_func ("/mconn-utils/find-urls/none", test_find_urls_none);
  38. Test.add_func ("/mconn-utils/find-urls/special", test_find_urls_special);
  39. Test.run ();
  40. }