[gnote] Add unit test runner with one unit test
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add unit test runner with one unit test
- Date: Sun, 22 Jan 2017 12:23:55 +0000 (UTC)
commit d6258560af037f58a7289520fc49aa596594e288
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Jan 22 14:18:27 2017 +0200
Add unit test runner with one unit test
src/Makefile.am | 11 +++++++++
src/test/runner.cpp | 27 +++++++++++++++++++++++
src/test/unit/stringutests.cpp | 47 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c7c8d84..638e632 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,6 +28,17 @@ check_PROGRAMS = trietest stringtest notetest dttest uritest filestest \
TESTS = trietest stringtest notetest dttest uritest filestest \
fileinfotest xmlreadertest notemanagertest gnotesyncclienttest
+if HAVE_UNITTESTCPP
+check_PROGRAMS += gnoteunittests
+TESTS += gnoteunittests
+
+gnoteunittests_SOURCES = \
+ test/runner.cpp \
+ test/unit/stringutests.cpp \
+ $(NULL)
+gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
+endif
+
trietest_SOURCES = test/trietest.cpp
trietest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
diff --git a/src/test/runner.cpp b/src/test/runner.cpp
new file mode 100644
index 0000000..1495f5a
--- /dev/null
+++ b/src/test/runner.cpp
@@ -0,0 +1,27 @@
+/*
+ * 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>
+
+int main(int /*argc*/, char ** /*argv*/)
+{
+ return UnitTest::RunAllTests();
+}
+
diff --git a/src/test/unit/stringutests.cpp b/src/test/unit/stringutests.cpp
new file mode 100644
index 0000000..5ae3aa1
--- /dev/null
+++ b/src/test/unit/stringutests.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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/string.hpp"
+
+
+SUITE(String)
+{
+ TEST(replace_first)
+ {
+ Glib::ustring res;
+ res = sharp::string_replace_first("foo bar baz", "ba", "");
+ CHECK_EQUAL("foo r baz", res);
+
+ res = sharp::string_replace_first("foo bar baz", "foo", "bingo");
+ CHECK_EQUAL("bingo bar baz", res);
+
+ res = sharp::string_replace_first("foo bar baz", "baz", "bar");
+ CHECK_EQUAL("foo bar bar", res);
+
+ res = sharp::string_replace_first("foo bar baz", "", "bar");
+ CHECK_EQUAL("foo bar baz", res);
+
+ res = sharp::string_replace_first("", "foo", "bar");
+ CHECK_EQUAL("", res);
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]