[gnote] Convert FileInfo test into unit test



commit 7f0dd1bacd899df31ac87eec05b6ab8aa67eb811
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 28 12:19:51 2017 +0200

    Convert FileInfo test into unit test

 src/Makefile.am                  |    8 ++---
 src/test/fileinfotest.cpp        |   62 --------------------------------------
 src/test/unit/fileinfoutests.cpp |   56 ++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 67 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b802b7..0c41825 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,9 +24,9 @@ GNOTE_LIBS = libgnote.la $(LIBGNOTE_LIBS)
 lib_LTLIBRARIES = libgnote.la
 bin_PROGRAMS = gnote
 check_PROGRAMS = trietest notetest uritest \
-       fileinfotest xmlreadertest notemanagertest gnotesyncclienttest
+       xmlreadertest notemanagertest gnotesyncclienttest
 TESTS = trietest notetest uritest \
-       fileinfotest xmlreadertest notemanagertest gnotesyncclienttest
+       xmlreadertest notemanagertest gnotesyncclienttest
 
 if HAVE_UNITTESTCPP
 check_PROGRAMS += gnoteunittests
@@ -36,6 +36,7 @@ gnoteunittests_SOURCES = \
        test/runner.cpp \
        test/unit/datetimeutests.cpp \
        test/unit/filesutests.cpp \
+       test/unit/fileinfoutests.cpp \
        test/unit/stringutests.cpp \
        $(NULL)
 gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
@@ -45,9 +46,6 @@ endif
 trietest_SOURCES = test/trietest.cpp
 trietest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
 
-fileinfotest_SOURCES = test/fileinfotest.cpp
-fileinfotest_LDADD = libgnote.la @LIBGLIBMM_LIBS@ -lgiomm-2.4
-
 uritest_SOURCES = test/uritest.cpp
 uritest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
 
diff --git a/src/test/unit/fileinfoutests.cpp b/src/test/unit/fileinfoutests.cpp
new file mode 100644
index 0000000..e717719
--- /dev/null
+++ b/src/test/unit/fileinfoutests.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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/fileinfo.hpp"
+
+
+SUITE(FileInfo)
+{
+  TEST(get_name)
+  {
+    sharp::FileInfo file_info1("/foo/bar/baz.txt");
+    sharp::FileInfo file_info2("/foo/bar/baz.");
+    sharp::FileInfo file_info3("/foo/bar/baz");
+    sharp::FileInfo file_info4("/foo/bar/..");
+    sharp::FileInfo file_info5("/foo/bar/");
+
+    CHECK_EQUAL("baz.txt", file_info1.get_name());
+    CHECK_EQUAL("baz.", file_info2.get_name());
+    CHECK_EQUAL("baz", file_info3.get_name());
+    CHECK_EQUAL("..", file_info4.get_name());
+    CHECK_EQUAL("bar", file_info5.get_name());
+  }
+
+  TEST(get_extension)
+  {
+    sharp::FileInfo file_info1("/foo/bar/baz.txt");
+    sharp::FileInfo file_info2("/foo/bar/baz.");
+    sharp::FileInfo file_info3("/foo/bar/baz");
+    sharp::FileInfo file_info4("/foo/bar/..");
+    sharp::FileInfo file_info5("/foo/bar/");
+
+    CHECK_EQUAL(".txt", file_info1.get_extension());
+    CHECK_EQUAL(".", file_info2.get_extension());
+    CHECK_EQUAL("", file_info3.get_extension());
+    CHECK_EQUAL("", file_info4.get_extension());
+    CHECK_EQUAL("", file_info5.get_extension());
+  }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]