test_urlutils.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /***************************************************************************
  2. test_urlutils.h
  3. --------------------
  4. begin : Jun 2020
  5. copyright : (C) 2020 by Ivan Ivanov
  6. email : ivan@opengis.ch
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #define CATCH_CONFIG_MAIN
  17. #include "utils/urlutils.h"
  18. #include <QDebug>
  19. #include <QFileInfo>
  20. #include "catch2.h"
  21. TEST_CASE( "UrlUtils" )
  22. {
  23. // should be considered relative
  24. REQUIRE( UrlUtils::isRelativeOrFileUrl( QStringLiteral( "path/to/file" ) ) );
  25. REQUIRE( UrlUtils::isRelativeOrFileUrl( QStringLiteral( "/path/to/file" ) ) );
  26. REQUIRE( UrlUtils::isRelativeOrFileUrl( QStringLiteral( "file:///path/to/file" ) ) );
  27. // should NOT be considered relative
  28. REQUIRE( !UrlUtils::isRelativeOrFileUrl( QStringLiteral( "http://osm.org" ) ) );
  29. REQUIRE( !UrlUtils::isRelativeOrFileUrl( QStringLiteral( "http://osm.org/test?query=1" ) ) );
  30. REQUIRE( !UrlUtils::isRelativeOrFileUrl( QStringLiteral( "https://osm.org/test?query=1" ) ) );
  31. }