[gnote] Convert files test into unit test
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Convert files test into unit test
- Date: Sat, 28 Jan 2017 11:28:02 +0000 (UTC)
commit dc27975b637f4eed9132afb13004cebd4b0392f5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Jan 28 12:07:32 2017 +0200
Convert files test into unit test
src/Makefile.am | 8 ++---
src/test/filestest.cpp | 74 -----------------------------------------
src/test/unit/filesutests.cpp | 62 ++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 79 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8e955f3..0b802b7 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 filestest \
+check_PROGRAMS = trietest notetest uritest \
fileinfotest xmlreadertest notemanagertest gnotesyncclienttest
-TESTS = trietest notetest dttest uritest filestest \
+TESTS = trietest notetest uritest \
fileinfotest xmlreadertest notemanagertest gnotesyncclienttest
if HAVE_UNITTESTCPP
@@ -35,6 +35,7 @@ TESTS += gnoteunittests
gnoteunittests_SOURCES = \
test/runner.cpp \
test/unit/datetimeutests.cpp \
+ test/unit/filesutests.cpp \
test/unit/stringutests.cpp \
$(NULL)
gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
@@ -44,9 +45,6 @@ endif
trietest_SOURCES = test/trietest.cpp
trietest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
-filestest_SOURCES = test/filestest.cpp
-filestest_LDADD = libgnote.la @LIBGLIBMM_LIBS@ -lgiomm-2.4
-
fileinfotest_SOURCES = test/fileinfotest.cpp
fileinfotest_LDADD = libgnote.la @LIBGLIBMM_LIBS@ -lgiomm-2.4
diff --git a/src/test/unit/filesutests.cpp b/src/test/unit/filesutests.cpp
new file mode 100644
index 0000000..e0a39ad
--- /dev/null
+++ b/src/test/unit/filesutests.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 <glibmm/miscutils.h>
+#include <UnitTest++/UnitTest++.h>
+
+#include "sharp/files.hpp"
+
+
+SUITE(files)
+{
+ TEST(basename)
+ {
+ CHECK_EQUAL("baz", sharp::file_basename("/foo/bar/baz.txt"));
+ CHECK_EQUAL("baz", sharp::file_basename("/foo/bar/baz"));
+ CHECK_EQUAL(".", sharp::file_basename("/foo/bar/.."));
+ CHECK_EQUAL("bar", sharp::file_basename("/foo/bar/"));
+ }
+
+ TEST(dirname)
+ {
+ CHECK_EQUAL("/foo/bar", sharp::file_dirname("/foo/bar/baz.txt"));
+ CHECK_EQUAL("/foo/bar", sharp::file_dirname("/foo/bar/baz"));
+ CHECK_EQUAL("/foo/bar", sharp::file_dirname("/foo/bar/.."));
+ CHECK_EQUAL("/foo/bar", sharp::file_dirname("/foo/bar/"));
+ }
+
+ TEST(filename)
+ {
+ CHECK_EQUAL("baz.txt", sharp::file_filename("/foo/bar/baz.txt"));
+ CHECK_EQUAL("baz", sharp::file_filename("/foo/bar/baz"));
+ CHECK_EQUAL("..", sharp::file_filename("/foo/bar/.."));
+ CHECK_EQUAL("bar", sharp::file_filename("/foo/bar/"));
+ }
+
+ TEST(exists)
+ {
+ Glib::ustring dir = Glib::get_current_dir();
+
+ CHECK(sharp::file_exists(dir) == false);
+ // Very unlikely to exist.
+ CHECK(sharp::file_exists(__FILE__ __FILE__) == false);
+ CHECK(sharp::file_exists(__FILE__) == true);
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]