- Added Url view option configutation testcase
authorMarius Tomaschewski <mt@suse.de>
Thu, 4 May 2006 11:09:42 +0000 (11:09 +0000)
committerMarius Tomaschewski <mt@suse.de>
Thu, 4 May 2006 11:09:42 +0000 (11:09 +0000)
testsuite/zypp/tests/Makefile.am
testsuite/zypp/tests/Url.cc [new file with mode: 0644]
testsuite/zypp/zypp.test/Url.exp [new file with mode: 0644]

index 65725f0..6259ecf 100644 (file)
@@ -7,7 +7,7 @@ SUBDIRS =
 
 ## ##################################################
 
-noinst_PROGRAMS = Arch Url1 Url2 Url3 Url4 Url5 \
+noinst_PROGRAMS = Arch Url1 Url2 Url3 Url4 Url5 Url \
        RWPtr \
        Edition         \
        Capabilities    \
@@ -25,6 +25,7 @@ Url2_SOURCES = Url2.cc
 Url3_SOURCES = Url3.cc
 Url4_SOURCES = Url4.cc
 Url5_SOURCES = Url5.cc
+Url_SOURCES  = Url.cc
 RWPtr_SOURCES = RWPtr.cc
 Edition_SOURCES = Edition.cc
 Capabilities_SOURCES = Capabilities.cc
diff --git a/testsuite/zypp/tests/Url.cc b/testsuite/zypp/tests/Url.cc
new file mode 100644 (file)
index 0000000..e4fda4f
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+** Check if the url by scheme repository works, e.g.
+** if there are some initialization order problems
+** (ViewOption) causing asString to format its string
+** differently than configured.
+*/
+#include "zypp/Url.h"
+#include <stdexcept>
+#include <iostream>
+#include <cassert>
+
+int main(void)
+{
+  try
+  {
+    std::string str, one, two;
+    zypp::Url   url;
+
+
+    // asString & asCompleteString should not print "mailto://"
+    str = "mailto:feedback@example.com?subject=hello";
+    one = str;
+    two = str;
+    url = str;
+    std::cout << "STR: " << str                    << std::endl;
+    std::cout << "ONE: " << url.asString()         << std::endl;
+    std::cout << "TWO: " << url.asCompleteString() << std::endl;
+    assert( one == url.asString());
+    assert( two == url.asCompleteString());
+    std::cout << std::endl;
+
+
+    // asString & asCompleteString should add empty authority
+    // "dvd://...", except we request to avoid it.
+    str = "dvd:/srv/ftp";
+    one = "dvd:///srv/ftp";
+    two = "dvd:///srv/ftp";
+    url = str;
+    std::cout << "STR: " << str                    << std::endl;
+    std::cout << "ONE: " << url.asString()         << std::endl;
+    std::cout << "TWO: " << url.asCompleteString() << std::endl;
+    assert( one == url.asString());
+    assert( two == url.asCompleteString());
+    assert( str  == url.asString(zypp::url::ViewOptions() -
+                                 zypp::url::ViewOption::EMPTY_AUTHORITY));
+    std::cout << std::endl;
+
+
+    // asString shouldn't print the password, asCompleteString should
+    // further, the "//" at the begin of the path should become "/%2F"
+    str = "ftp://user:pass@localhost//srv/ftp";
+    one = "ftp://user@localhost/%2Fsrv/ftp";
+    two = "ftp://user:pass@localhost/%2Fsrv/ftp";
+    url = str;
+    std::cout << "STR: " << str                    << std::endl;
+    std::cout << "ONE: " << url.asString()         << std::endl;
+    std::cout << "TWO: " << url.asCompleteString() << std::endl;
+    assert( one == url.asString());
+    assert( two == url.asCompleteString());
+    std::cout << std::endl;
+
+
+    // asString shouldn't print the password, asCompleteString should
+    // further, the "//" at the begin of the path should be keept.
+    str = "http://user:pass@localhost//srv/ftp";
+    one = "http://user@localhost//srv/ftp";
+    two = str;
+    url = str;
+    std::cout << "STR: " << str                    << std::endl;
+    std::cout << "ONE: " << url.asString()         << std::endl;
+    std::cout << "TWO: " << url.asCompleteString() << std::endl;
+    assert( one == url.asString());
+    assert( two == url.asCompleteString());
+    std::cout << std::endl;
+
+  }
+  catch(const zypp::url::UrlException &e)
+  {
+    ZYPP_CAUGHT(e);
+    return 2;
+  }
+
+  return 0;
+}
+
+// vim: set ts=2 sts=2 sw=2 ai et:
diff --git a/testsuite/zypp/zypp.test/Url.exp b/testsuite/zypp/zypp.test/Url.exp
new file mode 100644 (file)
index 0000000..9959e90
--- /dev/null
@@ -0,0 +1,4 @@
+# Url.exp
+# run tests for Url
+
+  shouldPass "Url"