[gnote] Convert Uri test into unit test
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Convert Uri test into unit test
- Date: Sat, 28 Jan 2017 11:28:12 +0000 (UTC)
commit 91808aa8a4e94f2f422f59d5fd45d47bc46d4e77
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Jan 28 12:30:08 2017 +0200
Convert Uri test into unit test
src/Makefile.am | 8 ++---
src/test/unit/uriutests.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++
src/test/uritest.cpp | 52 -----------------------------------
3 files changed, 66 insertions(+), 57 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c41825..ee1af1c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,9 +23,9 @@ GNOTE_LIBS = libgnote.la $(LIBGNOTE_LIBS)
lib_LTLIBRARIES = libgnote.la
bin_PROGRAMS = gnote
-check_PROGRAMS = trietest notetest uritest \
+check_PROGRAMS = trietest notetest \
xmlreadertest notemanagertest gnotesyncclienttest
-TESTS = trietest notetest uritest \
+TESTS = trietest notetest \
xmlreadertest notemanagertest gnotesyncclienttest
if HAVE_UNITTESTCPP
@@ -38,6 +38,7 @@ gnoteunittests_SOURCES = \
test/unit/filesutests.cpp \
test/unit/fileinfoutests.cpp \
test/unit/stringutests.cpp \
+ test/unit/uriutests.cpp \
$(NULL)
gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
endif
@@ -46,9 +47,6 @@ endif
trietest_SOURCES = test/trietest.cpp
trietest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
-uritest_SOURCES = test/uritest.cpp
-uritest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
-
xmlreadertest_SOURCES = test/xmlreadertest.cpp
xmlreadertest_LDADD = libgnote.la @LIBXML_LIBS@
diff --git a/src/test/unit/uriutests.cpp b/src/test/unit/uriutests.cpp
new file mode 100644
index 0000000..a3ef8bc
--- /dev/null
+++ b/src/test/unit/uriutests.cpp
@@ -0,0 +1,63 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2017 Aurimas Cernius
+ *
+ * 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+
+#include <UnitTest++/UnitTest++.h>
+
+#include "sharp/uri.hpp"
+
+
+SUITE(Uri)
+{
+ TEST(is_file)
+ {
+ sharp::Uri uri1("http://bugzilla.gnome.org/");
+ sharp::Uri uri2("https://bugzilla.gnome.org/");
+ sharp::Uri uri3("file:///tmp/foo.txt");
+
+ CHECK(!uri1.is_file());
+ CHECK(!uri2.is_file());
+ CHECK(uri3.is_file());
+ }
+
+ TEST(local_path)
+ {
+ sharp::Uri uri1("http://bugzilla.gnome.org/");
+ sharp::Uri uri2("https://bugzilla.gnome.org/");
+ sharp::Uri uri3("file:///tmp/foo.txt");
+
+ CHECK_EQUAL("https://bugzilla.gnome.org/", uri2.local_path());
+ CHECK_EQUAL("http://bugzilla.gnome.org/", uri1.local_path());
+ CHECK_EQUAL("/tmp/foo.txt", uri3.local_path());
+ }
+
+ TEST(get_host)
+ {
+ sharp::Uri uri1("http://bugzilla.gnome.org/");
+ sharp::Uri uri2("https://bugzilla.gnome.org/");
+ sharp::Uri uri3("file:///tmp/foo.txt");
+
+ CHECK_EQUAL("bugzilla.gnome.org", uri1.get_host());
+ CHECK_EQUAL("bugzilla.gnome.org", uri2.get_host());
+ CHECK_EQUAL("", uri3.get_host());
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]