[glom] Added an extra test for the Document class.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Added an extra test for the Document class.
- Date: Mon, 28 Nov 2011 13:30:53 +0000 (UTC)
commit 8744e2ea35ca6b005833607c46a9fc795afce8a8
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Nov 28 14:30:44 2011 +0100
Added an extra test for the Document class.
* tests/test_document_change.cc: The beginnings of another test,
to check that what we set is what we later get.
ChangeLog | 7 +++
Makefile_tests.am | 6 +++
tests/test_document_change.cc | 85 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 946fbf0..9d291da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-11-28 Murray Cumming <murrayc murrayc com>
+ Added an extra test for the Document class.
+
+ * tests/test_document_change.cc: The beginnings of another test,
+ to check that what we set is what we later get.
+
+2011-11-28 Murray Cumming <murrayc murrayc com>
+
SQLite: Avoid a warning about int types for summary fields.
* glom/libglom/data_structure/glomconversions.cc:
diff --git a/Makefile_tests.am b/Makefile_tests.am
index 876c6ab..1e9a59d 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -23,6 +23,7 @@ check_PROGRAMS = \
glom/libglom/example_document_load \
glom/libglom/test_sharedptr_layoutitem \
tests/test_document_load \
+ tests/test_document_change \
tests/test_document_autosave \
tests/test_parsing_time \
tests/test_signal_reemit \
@@ -43,6 +44,7 @@ check_PROGRAMS = \
tests/import/test_signals
TESTS = tests/test_document_load \
+ tests/test_document_change \
tests/test_document_autosave \
tests/test_parsing_time \
tests/test_signal_reemit \
@@ -96,6 +98,10 @@ tests_test_document_load_SOURCES = tests/test_document_load.cc
tests_test_document_load_LDADD = $(tests_ldadd)
tests_test_document_load_CPPFLAGS = $(tests_cppflags)
+tests_test_document_change_SOURCES = tests/test_document_change.cc
+tests_test_document_change_LDADD = $(tests_ldadd)
+tests_test_document_change_CPPFLAGS = $(tests_cppflags)
+
tests_test_document_autosave_SOURCES = tests/test_document_autosave.cc
tests_test_document_autosave_LDADD = $(tests_ldadd)
tests_test_document_autosave_CPPFLAGS = $(tests_cppflags)
diff --git a/tests/test_document_change.cc b/tests/test_document_change.cc
new file mode 100644
index 0000000..706d22d
--- /dev/null
+++ b/tests/test_document_change.cc
@@ -0,0 +1,85 @@
+/* Glom
+ *
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * 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 2 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, write to the
+71 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libglom/document/document.h>
+#include <libglom/init.h>
+#include <giomm/file.h>
+#include <glibmm/convert.h>
+#include <glibmm/miscutils.h>
+
+#include <iostream>
+
+template<typename T_Container>
+bool contains(const T_Container& container, const Glib::ustring& name)
+{
+ typename T_Container::const_iterator iter =
+ std::find(container.begin(), container.end(), name);
+ return iter != container.end();
+}
+
+template<typename T_Container>
+bool contains_named(const T_Container& container, const Glib::ustring& name)
+{
+ typedef typename T_Container::value_type::object_type type_item;
+ typename T_Container::const_iterator iter =
+ std::find_if(container.begin(), container.end(),
+ Glom::predicate_FieldHasName<type_item>(name));
+ return iter != container.end();
+}
+
+int main()
+{
+ Glom::libglom_init();
+
+ Glom::Document document;
+
+ //Test some simple get/set operations:
+ const char* title = "Music Collection";
+ document.set_database_title(title);
+ g_assert(document.get_database_title() == title);
+
+ const char* value = "someuser";
+ document.set_connection_user(value);
+ g_assert(document.get_connection_user() == value);
+
+ value = "someserver";
+ document.set_connection_server(value);
+ g_assert(document.get_connection_server() == value);
+
+ value = "somedb";
+ document.set_connection_database(value);
+ g_assert(document.get_connection_database() == value);
+
+ const guint port = 12345;
+ document.set_connection_port(port);
+ g_assert(document.get_connection_port() == port);
+
+ const bool try_other_ports = false;
+ document.set_connection_try_other_ports(try_other_ports);
+ g_assert(document.get_connection_try_other_ports() == try_other_ports);
+
+ value = "somescriptcontents";
+ document.set_startup_script(value);
+ g_assert(document.get_startup_script() == value);
+
+ Glom::libglom_deinit();
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]