From 28ecf041ee20b4455b68ecfa31e988640d7230ab Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 8 Dec 2008 20:29:12 +0000 Subject: "make check" now compiles and runs on Linux. (bzr r6973) --- src/test-stubs.cpp | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) (limited to 'src/test-stubs.cpp') diff --git a/src/test-stubs.cpp b/src/test-stubs.cpp index efc5cf7d8..449cce1b6 100644 --- a/src/test-stubs.cpp +++ b/src/test-stubs.cpp @@ -1,4 +1,115 @@ +/** @file + * @brief Alternate stub implementations for some functions. + * + * This file exists only for the benefit of the linker when building tests, + * to avoid circular dependencies. If some test causes link errors because of a function + * it doesn't need, feel free to add a stub here. + */ +/* Authors: Krzysztof KosiƄski + * This file is in the public domain. + */ + +#include "preferences.h" +#include +#include +#include +#include -// dummy functions to prevent link errors int sp_main_gui(int /*argc*/, char const **/*argv*/) { return 0; } int sp_main_console(int /*argc*/, char const **/*argv*/) { return 0; } + +// stubbed out preferences implementation using a simple map +namespace Inkscape { + +std::map _prefs; + +Preferences::Preferences() : + _prefs_basename(""), + _prefs_dir(""), + _prefs_filename(""), + _prefs_doc(NULL), + _use_gui(true), + _quiet(false), + _loaded(false), + _writable(false) +{ +} + +Preferences::~Preferences() +{ +} + +void Preferences::load(bool use_gui, bool quiet) {} +void Preferences::save() {} + +// getter methods + +Preferences::Entry const Preferences::getEntry(Glib::ustring const &pref_path) +{ + return _prefs[pref_path]; +} +void Preferences::setBool(Glib::ustring const &pref_path, bool value) +{ + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) (value ? "1" : "0")); +} +void Preferences::setInt(Glib::ustring const &pref_path, int value) +{ + gchar *intstr = (gchar*) g_malloc(32); + g_snprintf(intstr, 32, "%d", value); + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) intstr); +} +void Preferences::setDouble(Glib::ustring const &pref_path, double value) +{ + gchar *buf = (gchar*) g_malloc(G_ASCII_DTOSTR_BUF_SIZE); + g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) buf); +} +void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value) +{ + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) g_strdup(value.data())); +} + +bool Preferences::_extractBool(Entry const &v) +{ + gchar const *s = static_cast(v._value); + if ( !s[0] || !strcmp(s, "0") || !strcmp(s, "false") ) return false; + return true; +} +int Preferences::_extractInt(Entry const &v) +{ + gchar const *s = static_cast(v._value); + if ( !strcmp(s, "true") ) return true; + if ( !strcmp(s, "false") ) return false; + return atoi(s); +} +double Preferences::_extractDouble(Entry const &v) +{ + gchar const *s = static_cast(v._value); + return g_ascii_strtod(s, NULL); +} + +Glib::ustring Preferences::_extractString(Entry const &v) +{ + return Glib::ustring(static_cast(v._value)); +} +Preferences::Entry const Preferences::_create_pref_value(Glib::ustring const &path, void const *ptr) +{ + return Entry(path, ptr); +} + +Preferences *Preferences::_instance = NULL; + + +} // namespace Inkscape + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3