summaryrefslogtreecommitdiffstats
path: root/src/piklab-test/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/piklab-test/misc')
-rw-r--r--src/piklab-test/misc/Makefile.am10
-rw-r--r--src/piklab-test/misc/misc_check.cpp99
-rw-r--r--src/piklab-test/misc/misc_check.h20
3 files changed, 129 insertions, 0 deletions
diff --git a/src/piklab-test/misc/Makefile.am b/src/piklab-test/misc/Makefile.am
new file mode 100644
index 0000000..e21c3d1
--- /dev/null
+++ b/src/piklab-test/misc/Makefile.am
@@ -0,0 +1,10 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_PROGRAMS = misc_check
+OBJ = $(top_builddir)/src/piklab-test/base/libtest.la $(top_builddir)/src/common/cli/libcli.la \
+ $(top_builddir)/src/common/global/libglobal.la $(top_builddir)/src/common/common/libcommon.la
+misc_check_DEPENDENCIES = $(OBJ)
+misc_check_LDADD = $(OBJ) $(LIB_KIO)
+misc_check_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+misc_check_SOURCES = misc_check.cpp
diff --git a/src/piklab-test/misc/misc_check.cpp b/src/piklab-test/misc/misc_check.cpp
new file mode 100644
index 0000000..3f14287
--- /dev/null
+++ b/src/piklab-test/misc/misc_check.cpp
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "misc_check.h"
+
+#include "common/global/purl.h"
+
+//----------------------------------------------------------------------------
+bool MiscCheck::execute()
+{
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl(QString::null);
+ if ( !url.isEmpty() ) TEST_FAILED("isEmpty");
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("");
+ if ( !url.isEmpty() ) TEST_FAILED("isEmpty");
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("/");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ if ( url.path()!="/" ) TEST_FAILED("");
+ if ( url.filepath()!="/" ) TEST_FAILED(url.filepath());
+ if ( url.unterminatedPath()!="/" ) TEST_FAILED("");
+ if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("test");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( !url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ if ( url.filename()!="test" ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("/test");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ if ( url.path()!="/" ) TEST_FAILED("");
+ if ( url.unterminatedPath()!="/" ) TEST_FAILED("");
+ if ( url.filepath()!="/test" ) TEST_FAILED(url.filepath());
+ if ( url.filename()!="test" ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("/test/");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ if ( url.path()!="/test/" ) TEST_FAILED("");
+ if ( url.unterminatedPath()!="/test" ) TEST_FAILED("");
+ if ( url.filepath()!="/test/" ) TEST_FAILED(url.filepath());
+ if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("c:/test");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ PURL::Url url2 = PURL::Url::fromPathOrUrl("c:/");
+ if ( url.path()!=url2.path() ) TEST_FAILED(url.path());
+ if ( url==url2 ) TEST_FAILED(url.path());
+ if ( url.filename()!="test" ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url = PURL::Url::fromPathOrUrl("d:/test/");
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( !url.isLocal() ) TEST_FAILED("isLocal");
+ if ( !url.filename().isEmpty() ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+ {
+ PURL::Url url(KURL::fromPathOrURL("http://test.net/test"));
+ if ( url.isEmpty() ) TEST_FAILED("isEmpty");
+ if ( url.isRelative() ) TEST_FAILED("isRelative");
+ if ( url.isLocal() ) TEST_FAILED("isLocal");
+ if ( url.filename()!="test" ) TEST_FAILED(url.filename());
+ TEST_PASSED;
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+TEST_MAIN(MiscCheck)
diff --git a/src/piklab-test/misc/misc_check.h b/src/piklab-test/misc/misc_check.h
new file mode 100644
index 0000000..a36b3cf
--- /dev/null
+++ b/src/piklab-test/misc/misc_check.h
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef MISC_CHECK_H
+#define MISC_CHECK_H
+
+#include "piklab-test/base/main_test.h"
+
+class MiscCheck : public Test
+{
+protected:
+ virtual bool execute();
+};
+
+#endif