[gnote] Convert XmlReader test into unit test



commit 0d1e5c1102527d37355ae115a59380cc99543449
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 28 12:49:03 2017 +0200

    Convert XmlReader test into unit test

 src/Makefile.am                   |    8 +--
 src/test/unit/xmlreaderutests.cpp |   77 +++++++++++++++++++++++++++++++++++
 src/test/xmlreadertest.cpp        |   81 -------------------------------------
 3 files changed, 80 insertions(+), 86 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ee1af1c..9a088ee 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 \
-       xmlreadertest notemanagertest gnotesyncclienttest
+       notemanagertest gnotesyncclienttest
 TESTS = trietest notetest \
-       xmlreadertest notemanagertest gnotesyncclienttest
+       notemanagertest gnotesyncclienttest
 
 if HAVE_UNITTESTCPP
 check_PROGRAMS += gnoteunittests
@@ -39,6 +39,7 @@ gnoteunittests_SOURCES = \
        test/unit/fileinfoutests.cpp \
        test/unit/stringutests.cpp \
        test/unit/uriutests.cpp \
+       test/unit/xmlreaderutests.cpp \
        $(NULL)
 gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
 endif
@@ -47,9 +48,6 @@ endif
 trietest_SOURCES = test/trietest.cpp
 trietest_LDADD = libgnote.la @LIBGLIBMM_LIBS@
 
-xmlreadertest_SOURCES = test/xmlreadertest.cpp
-xmlreadertest_LDADD = libgnote.la @LIBXML_LIBS@
-
 notetest_SOURCES = test/notetest.cpp
 notetest_LDADD =  $(GNOTE_LIBS) -lX11
 
diff --git a/src/test/unit/xmlreaderutests.cpp b/src/test/unit/xmlreaderutests.cpp
new file mode 100644
index 0000000..485f1f4
--- /dev/null
+++ b/src/test/unit/xmlreaderutests.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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/xmlreader.hpp"
+
+
+SUITE(XmlReader)
+{
+  TEST(simple_test)
+  {
+    sharp::XmlReader xml;
+
+    Glib::ustring content = "<note-content xmlns:link=\"http://beatniksoftware.com/tomboy/link\";>"
+                              "Start Here\n\n"
+                              "<bold>Welcome to Gnote!</bold>\n\n"
+                              "Use this \"Start Here\" note to begin organizing "
+                              "your ideas and thoughts.\n\n"
+                              "You can create new notes to hold your ideas by "
+                              "selecting the \"Create New Note\" item from the "
+                              "Gnote menu in your GNOME Panel. "
+                              "Your note will be saved automatically.\n\n"
+                              "Then organize the notes you create by linking "
+                              "related notes and ideas together!\n\n"
+                              "We've created a note called "
+                              "<link:internal>Using Links in Gnote</link:internal>. "
+                              "Notice how each time we type <link:internal>Using "
+                              "Links in Gnote</link:internal> it automatically "
+                              "gets underlined?  Click on the link to open the note."
+                            "</note-content>";
+
+    xml.load_buffer(content);
+
+    CHECK(xml.read());
+    CHECK_EQUAL(XML_READER_TYPE_ELEMENT, xml.get_node_type());
+    CHECK_EQUAL("note-content", xml.get_name());
+    CHECK_EQUAL("http://beatniksoftware.com/tomboy/link";, xml.get_attribute("xmlns:link"));
+
+    CHECK_EQUAL("Start Here\n\n"
+                  "<bold>Welcome to Gnote!</bold>\n\n"
+                  "Use this \"Start Here\" note to begin organizing "
+                  "your ideas and thoughts.\n\n"
+                  "You can create new notes to hold your ideas by "
+                  "selecting the \"Create New Note\" item from the "
+                  "Gnote menu in your GNOME Panel. "
+                  "Your note will be saved automatically.\n\n"
+                  "Then organize the notes you create by linking "
+                  "related notes and ideas together!\n\n"
+                  "We've created a note called <link:internal "
+                  "xmlns:link=\"http://beatniksoftware.com/tomboy/link\";>Using Links in 
Gnote</link:internal>. "
+                  "Notice how each time we type <link:internal "
+                  "xmlns:link=\"http://beatniksoftware.com/tomboy/link\";>Using "
+                  "Links in Gnote</link:internal> it automatically "
+              "gets underlined?  Click on the link to open the note.", xml.read_inner_xml());
+    CHECK(xml.read());
+    CHECK_EQUAL(XML_READER_TYPE_TEXT, xml.get_node_type());
+  }
+}
+


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