mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move core-utils files with depedencies on qof to engine
I have done this in a separate commit from merging qof back into engine to keep an overview of changes
This commit is contained in:
parent
80be96219e
commit
848bb34741
@ -27,6 +27,7 @@ src/app-utils/gnc-component-manager.c
|
||||
src/app-utils/gnc-entry-quickfill.c
|
||||
src/app-utils/gnc-euro.c
|
||||
src/app-utils/gnc-exp-parser.c
|
||||
src/app-utils/gnc-gdate-utils.c
|
||||
src/app-utils/gnc-gettext-util.c
|
||||
src/app-utils/gnc-gsettings.c
|
||||
src/app-utils/gnc-helpers.c
|
||||
@ -113,9 +114,7 @@ src/bin/gnucash-bin.c
|
||||
src/core-utils/binreloc.c
|
||||
src/core-utils/core-utils.scm
|
||||
src/core-utils/gnc-environment.c
|
||||
src/core-utils/gnc-features.c
|
||||
src/core-utils/gnc-filepath-utils.c
|
||||
src/core-utils/gnc-gdate-utils.c
|
||||
src/core-utils/gnc-gkeyfile-utils.c
|
||||
src/core-utils/gnc-glib-utils.c
|
||||
src/core-utils/gnc-guile-utils.c
|
||||
@ -123,7 +122,6 @@ src/core-utils/gnc-jalali.c
|
||||
src/core-utils/gnc-locale-utils.c
|
||||
src/core-utils/gnc-path.c
|
||||
src/core-utils/gnc-prefs.c
|
||||
src/core-utils/gnc-uri-utils.c
|
||||
src/doc/doxygen_main_page.c
|
||||
src/engine/Account.c
|
||||
src/engine/business-core.scm
|
||||
@ -146,6 +144,7 @@ src/engine/gncEmployee.c
|
||||
src/engine/gnc-engine.c
|
||||
src/engine/gncEntry.c
|
||||
src/engine/gnc-event.c
|
||||
src/engine/gnc-features.c
|
||||
src/engine/gnc-hooks.c
|
||||
src/engine/gncIDSearch.c
|
||||
src/engine/gncInvoice.c
|
||||
@ -158,6 +157,7 @@ src/engine/gncOwner.c
|
||||
src/engine/gnc-pricedb.c
|
||||
src/engine/gnc-session.c
|
||||
src/engine/gncTaxTable.c
|
||||
src/engine/gnc-uri-utils.c
|
||||
src/engine/gncVendor.c
|
||||
src/engine/kvp-scm.cpp
|
||||
src/engine/policy.c
|
||||
|
@ -22,6 +22,7 @@ SET (app_utils_HEADERS
|
||||
gnc-entry-quickfill.h
|
||||
gnc-euro.h
|
||||
gnc-exp-parser.h
|
||||
gnc-gdate-utils.h
|
||||
gnc-gettext-util.h
|
||||
gnc-gsettings.h
|
||||
gnc-help-utils.h
|
||||
@ -63,6 +64,7 @@ SET (app_utils_SOURCES
|
||||
gnc-entry-quickfill.c
|
||||
gnc-euro.c
|
||||
gnc-exp-parser.c
|
||||
gnc-gdate-utils.c
|
||||
gnc-gettext-util.c
|
||||
gnc-gsettings.c
|
||||
gnc-helpers.c
|
||||
|
@ -53,6 +53,7 @@ libgncmod_app_utils_la_SOURCES = \
|
||||
gnc-entry-quickfill.c \
|
||||
gnc-euro.c \
|
||||
gnc-exp-parser.c \
|
||||
gnc-gdate-utils.c \
|
||||
gnc-gettext-util.c \
|
||||
gnc-gsettings.c \
|
||||
gnc-helpers.c \
|
||||
@ -80,6 +81,7 @@ gncinclude_HEADERS = \
|
||||
gnc-entry-quickfill.h \
|
||||
gnc-euro.h \
|
||||
gnc-exp-parser.h \
|
||||
gnc-gdate-utils.h \
|
||||
gnc-gettext-util.h \
|
||||
gnc-gsettings.h \
|
||||
gnc-help-utils.h \
|
||||
|
@ -26,23 +26,6 @@
|
||||
|
||||
#include "gnc-gdate-utils.h"
|
||||
|
||||
void
|
||||
gnc_gdate_set_today (GDate* gd)
|
||||
{
|
||||
GDate *today = gnc_g_date_new_today ();
|
||||
g_date_set_julian (gd, g_date_get_julian (today));
|
||||
g_date_free (today);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_gdate_set_time64 (GDate* gd, time64 time)
|
||||
{
|
||||
struct tm tm;
|
||||
gnc_localtime_r(&time, &tm);
|
||||
g_date_set_dmy (gd, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_gdate_equal(gconstpointer gda, gconstpointer gdb)
|
||||
{
|
@ -40,21 +40,6 @@
|
||||
|
||||
#include <gnc-date.h>
|
||||
|
||||
/** @name GDate time64 setters
|
||||
@{ */
|
||||
/** Set a GDate to the current day
|
||||
* @param theGDate: The date to act on
|
||||
*/
|
||||
void gnc_gdate_set_today (GDate* gd);
|
||||
|
||||
/** Set a GDate to a time64
|
||||
* @param theGDate: the date to act on
|
||||
* @param time: the time to set it to.
|
||||
*/
|
||||
void gnc_gdate_set_time64 (GDate* gd, time64 time);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @name GDate hash table support
|
||||
@{ */
|
||||
|
@ -17,15 +17,12 @@ SET (core_utils_SOURCES
|
||||
gnc-prefs.c
|
||||
gnc-environment.c
|
||||
gnc-filepath-utils.c
|
||||
gnc-features.c
|
||||
gnc-gdate-utils.c
|
||||
gnc-gkeyfile-utils.c
|
||||
gnc-glib-utils.c
|
||||
gnc-guile-utils.c
|
||||
gnc-jalali.c
|
||||
gnc-locale-utils.c
|
||||
gnc-path.c
|
||||
gnc-uri-utils.c
|
||||
)
|
||||
|
||||
# Add dependency on config.h
|
||||
@ -110,16 +107,13 @@ SET(core_utils_noinst_HEADERS
|
||||
gnc-prefs.h
|
||||
gnc-prefs-p.h
|
||||
gnc-environment.h
|
||||
gnc-features.h
|
||||
gnc-filepath-utils.h
|
||||
gnc-gdate-utils.h
|
||||
gnc-gkeyfile-utils.h
|
||||
gnc-glib-utils.h
|
||||
gnc-guile-utils.h
|
||||
gnc-jalali.h
|
||||
gnc-locale-utils.h
|
||||
gnc-path.h
|
||||
gnc-uri-utils.h
|
||||
)
|
||||
|
||||
SET(core_utils_ALL_SOURCES ${core_utils_SOURCES} ${core_utils_noinst_HEADERS})
|
||||
|
@ -6,16 +6,13 @@ libgnc_core_utils_la_SOURCES = \
|
||||
binreloc.c \
|
||||
gnc-prefs.c \
|
||||
gnc-environment.c \
|
||||
gnc-features.c \
|
||||
gnc-filepath-utils.c \
|
||||
gnc-gdate-utils.c \
|
||||
gnc-gkeyfile-utils.c \
|
||||
gnc-glib-utils.c \
|
||||
gnc-guile-utils.c \
|
||||
gnc-jalali.c \
|
||||
gnc-locale-utils.c \
|
||||
gnc-path.c \
|
||||
gnc-uri-utils.c \
|
||||
swig-core-utils-guile.c
|
||||
|
||||
libgnc_core_utils_la_LIBADD = \
|
||||
@ -31,16 +28,13 @@ noinst_HEADERS = \
|
||||
gnc-prefs.h \
|
||||
gnc-prefs-p.h \
|
||||
gnc-environment.h \
|
||||
gnc-features.h \
|
||||
gnc-filepath-utils.h \
|
||||
gnc-gdate-utils.h \
|
||||
gnc-gkeyfile-utils.h \
|
||||
gnc-glib-utils.h \
|
||||
gnc-guile-utils.h \
|
||||
gnc-jalali.h \
|
||||
gnc-locale-utils.h \
|
||||
gnc-path.h \
|
||||
gnc-uri-utils.h
|
||||
gnc-path.h
|
||||
|
||||
if BUILDING_FROM_VCS
|
||||
swig-core-utils-guile.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
|
||||
|
@ -14,7 +14,6 @@ MACRO(ADD_CORE_UTILS_TEST _TARGET _SOURCE_FILES)
|
||||
ENDMACRO()
|
||||
|
||||
ADD_CORE_UTILS_TEST(test-gnc-glib-utils test-gnc-glib-utils.c)
|
||||
ADD_CORE_UTILS_TEST(test-gnc-uri-utils test-gnc-uri-utils.c)
|
||||
ADD_CORE_UTILS_TEST(test-resolve-file-path test-resolve-file-path.c)
|
||||
|
||||
SET_DIST_LIST(test_core_utils_DIST CMakeLists.txt Makefile.am test-gnc-glib-utils.c test-gnc-uri-utils.c test-resolve-file-path.c)
|
||||
SET_DIST_LIST(test_core_utils_DIST CMakeLists.txt Makefile.am test-gnc-glib-utils.c test-resolve-file-path.c)
|
||||
|
@ -21,7 +21,6 @@ LDADD = \
|
||||
#
|
||||
|
||||
TESTS = \
|
||||
test-gnc-uri-utils \
|
||||
test-resolve-file-path \
|
||||
test-gnc-glib-utils
|
||||
|
||||
|
@ -41,9 +41,11 @@ SET (engine_HEADERS
|
||||
gnc-commodity.h
|
||||
gnc-engine.h
|
||||
gnc-event.h
|
||||
gnc-features.h
|
||||
gnc-hooks.h
|
||||
gnc-pricedb.h
|
||||
gnc-session.h
|
||||
gnc-uri-utils.h
|
||||
kvp-scm.h
|
||||
policy.h
|
||||
gncAddress.h
|
||||
@ -111,10 +113,12 @@ SET (engine_SOURCES
|
||||
gnc-commodity.c
|
||||
gnc-engine.c
|
||||
gnc-event.c
|
||||
gnc-features.c
|
||||
gnc-hooks.c
|
||||
gnc-lot.c
|
||||
gnc-pricedb.c
|
||||
gnc-session.c
|
||||
gnc-uri-utils.c
|
||||
gncmod-engine.c
|
||||
kvp-scm.cpp
|
||||
engine-helpers.c
|
||||
|
@ -34,10 +34,12 @@ libgncmod_engine_la_SOURCES = \
|
||||
gnc-commodity.c \
|
||||
gnc-engine.c \
|
||||
gnc-event.c \
|
||||
gnc-features.c \
|
||||
gnc-hooks.c \
|
||||
gnc-lot.c \
|
||||
gnc-pricedb.c \
|
||||
gnc-session.c \
|
||||
gnc-uri-utils.c \
|
||||
gncmod-engine.c \
|
||||
swig-engine.c \
|
||||
kvp-scm.cpp \
|
||||
@ -86,9 +88,11 @@ gncinclude_HEADERS = \
|
||||
gnc-commodity.h \
|
||||
gnc-engine.h \
|
||||
gnc-event.h \
|
||||
gnc-features.h \
|
||||
gnc-hooks.h \
|
||||
gnc-pricedb.h \
|
||||
gnc-session.h \
|
||||
gnc-uri-utils.h \
|
||||
kvp-scm.h \
|
||||
policy.h \
|
||||
gncAddress.h \
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "gnc-date.h"
|
||||
#include "qof.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-gdate-utils.h"
|
||||
#include "gnc-date.h"
|
||||
#include "Account.h"
|
||||
|
||||
#define LOG_MOD "gnc.engine.recurrence"
|
||||
@ -381,16 +381,23 @@ time64
|
||||
recurrenceGetPeriodTime(const Recurrence *r, guint period_num, gboolean end)
|
||||
{
|
||||
GDate date;
|
||||
Timespec ts;
|
||||
recurrenceNthInstance(r, period_num + (end ? 1 : 0), &date);
|
||||
if (end)
|
||||
{
|
||||
g_date_subtract_days(&date, 1);
|
||||
return gnc_time64_get_day_end_gdate(&date);
|
||||
ts = gnc_dmy2timespec_end (g_date_get_day(&date),
|
||||
g_date_get_month(&date),
|
||||
g_date_get_year (&date));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return gnc_time64_get_day_start_gdate(&date);
|
||||
ts = gnc_dmy2timespec (g_date_get_day(&date),
|
||||
g_date_get_month(&date),
|
||||
g_date_get_year (&date));
|
||||
}
|
||||
return timespecToTime64(ts);
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
|
@ -62,7 +62,7 @@ struct timeval
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-lot.h"
|
||||
#include "gnc-event.h"
|
||||
#include <gnc-gdate-utils.h>
|
||||
#include <gnc-date.h>
|
||||
#include "SchedXaction.h"
|
||||
#include "gncBusiness.h"
|
||||
#include <qofinstance-p.h>
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <time.h>
|
||||
#include <qof.h>
|
||||
#include <qofbookslots.h>
|
||||
#include <gnc-gdate-utils.h>
|
||||
#include <qofinstance-p.h>
|
||||
|
||||
#include "Account.h"
|
||||
@ -89,16 +88,17 @@ static void
|
||||
gnc_budget_init(GncBudget* budget)
|
||||
{
|
||||
BudgetPrivate* priv;
|
||||
GDate date;
|
||||
GDate *date;
|
||||
|
||||
priv = GET_PRIVATE(budget);
|
||||
priv->name = CACHE_INSERT(_("Unnamed Budget"));
|
||||
priv->description = CACHE_INSERT("");
|
||||
|
||||
priv->num_periods = 12;
|
||||
gnc_gdate_set_today (&date);
|
||||
g_date_subtract_days(&date, g_date_get_day(&date) - 1);
|
||||
recurrenceSet(&priv->recurrence, 1, PERIOD_MONTH, &date, WEEKEND_ADJ_NONE);
|
||||
date = gnc_g_date_new_today ();
|
||||
g_date_subtract_days(date, g_date_get_day(date) - 1);
|
||||
recurrenceSet(&priv->recurrence, 1, PERIOD_MONTH, date, WEEKEND_ADJ_NONE);
|
||||
g_date_free (date);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -35,6 +35,7 @@ ADD_ENGINE_TEST(test-commodities test-commodities.cpp)
|
||||
|
||||
SET(test_engine_SOURCES
|
||||
test-engine.c
|
||||
test-gnc-uri-utils.c
|
||||
utest-Account.cpp
|
||||
utest-Budget.c
|
||||
utest-Entry.c
|
||||
@ -109,6 +110,7 @@ SET(test_engine_SOURCES_DIST
|
||||
test-employee.c
|
||||
test-engine-kvp-properties.c
|
||||
test-engine.c
|
||||
test-gnc-uri-utils.c
|
||||
test-group-vs-book.cpp
|
||||
test-guid.cpp
|
||||
test-job.c
|
||||
|
@ -148,6 +148,7 @@ noinst_DATA: .scm-links
|
||||
|
||||
test_engine_SOURCES = \
|
||||
test-engine.c \
|
||||
test-gnc-uri-utils.c \
|
||||
utest-Account.cpp \
|
||||
utest-Budget.c \
|
||||
utest-Entry.c \
|
||||
|
@ -27,9 +27,12 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include "qof.h"
|
||||
#include "test-stuff.h"
|
||||
#include <unittest-support.h>
|
||||
#include "gnc-uri-utils.h"
|
||||
|
||||
static const gchar *suitename = "engine/uri-utils";
|
||||
void test_suite_gnc_uri_utils(void);
|
||||
|
||||
struct test_strings_struct
|
||||
{
|
||||
gchar *uri;
|
||||
@ -194,14 +197,11 @@ test_strings strs[] =
|
||||
{ NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0, NULL, FALSE },
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
/* TEST: gnc_uri_get_components */
|
||||
static void
|
||||
test_gnc_uri_get_components()
|
||||
{
|
||||
int i;
|
||||
|
||||
qof_init();
|
||||
|
||||
/* TEST: gnc_uri_get_components */
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gchar *tprotocol = NULL;
|
||||
@ -210,141 +210,124 @@ main(int argc, char **argv)
|
||||
gchar *tpassword = NULL;
|
||||
gchar *tpath = NULL;
|
||||
gint32 tport = 0;
|
||||
gboolean testresult;
|
||||
|
||||
gnc_uri_get_components( strs[i].uri, &tprotocol, &thostname,
|
||||
&tport, &tusername, &tpassword, &tpath );
|
||||
testresult = ( g_strcmp0 ( tprotocol, strs[i].protocol ) == 0 ) &
|
||||
( g_strcmp0 ( thostname, strs[i].hostname ) == 0 ) &
|
||||
( g_strcmp0 ( tusername, strs[i].username ) == 0 ) &
|
||||
( g_strcmp0 ( tpassword, strs[i].password ) == 0 ) &
|
||||
( g_strcmp0 ( tpath, strs[i].path ) == 0 ) &
|
||||
( tport == strs[i].port );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_get_components",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s, %s, %s, %s, %s, %d\n"
|
||||
" Got : %s, %s, %s, %s, %s, %d\n",
|
||||
strs[i].uri, strs[i].protocol, strs[i].hostname,
|
||||
strs[i].username, strs[i].password, strs[i].path, strs[i].port,
|
||||
tprotocol, thostname, tusername, tpassword, tpath, tport);
|
||||
g_assert_cmpstr ( tprotocol, ==, strs[i].protocol );
|
||||
g_assert_cmpstr ( thostname, ==, strs[i].hostname );
|
||||
g_assert_cmpstr ( tusername, ==, strs[i].username );
|
||||
g_assert_cmpstr ( tpassword, ==, strs[i].password );
|
||||
g_assert_cmpstr ( tpath, ==, strs[i].path );
|
||||
g_assert_cmpint ( tport, ==, strs[i].port );
|
||||
|
||||
g_free(tprotocol);
|
||||
g_free(thostname);
|
||||
g_free(tusername);
|
||||
g_free(tpassword);
|
||||
g_free(tpath);
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_get_protocol */
|
||||
static void
|
||||
test_gnc_uri_get_protocol()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gchar *tprotocol = NULL;
|
||||
gboolean testresult;
|
||||
|
||||
tprotocol = gnc_uri_get_protocol( strs[i].uri );
|
||||
testresult = ( g_strcmp0 ( tprotocol, strs[i].protocol ) == 0 );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_get_protocol",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].uri, strs[i].protocol, tprotocol );
|
||||
g_assert_cmpstr ( tprotocol, ==, strs[i].protocol );
|
||||
g_free(tprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_get_path */
|
||||
static void
|
||||
test_gnc_uri_get_path()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gchar *tpath = NULL;
|
||||
gboolean testresult;
|
||||
|
||||
tpath = gnc_uri_get_path( strs[i].uri );
|
||||
testresult = ( g_strcmp0 ( tpath, strs[i].path ) == 0 );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_get_path",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].uri, strs[i].path, tpath );
|
||||
g_assert_cmpstr ( tpath, ==, strs[i].path );
|
||||
g_free(tpath);
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_create_uri */
|
||||
static void
|
||||
test_gnc_uri_create_uri()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gchar *turi = NULL;
|
||||
gboolean testresult;
|
||||
|
||||
turi = gnc_uri_create_uri( strs[i].protocol, strs[i].hostname, strs[i].port,
|
||||
strs[i].username, strs[i].password, strs[i].path );
|
||||
testresult = ( g_strcmp0 ( turi, strs[i].created_uri ) == 0 );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_create_uri",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s, %s, %s, %s, %s, %d:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].protocol, strs[i].hostname,
|
||||
strs[i].username, strs[i].password, strs[i].path, strs[i].port,
|
||||
strs[i].created_uri, turi);
|
||||
g_assert_cmpstr ( turi, ==, strs[i].created_uri );
|
||||
g_free(turi);
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_normalize_uri */
|
||||
static void
|
||||
test_gnc_uri_normalize_uri()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* TEST: gnc_uri_normalize_uri */
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gchar *turi = NULL;
|
||||
gboolean testresult;
|
||||
|
||||
turi = gnc_uri_normalize_uri( strs[i].uri, strs[i].want_password );
|
||||
testresult = ( g_strcmp0 ( turi, strs[i].normalized_uri ) == 0 );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_normalize_uri",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].uri, strs[i].normalized_uri, turi );
|
||||
g_assert_cmpstr ( turi, ==, strs[i].normalized_uri );
|
||||
g_free(turi);
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_is_file_protocol */
|
||||
static void
|
||||
test_gnc_uri_is_file_protocol()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gboolean tis_file_protocol;
|
||||
gboolean testresult;
|
||||
|
||||
tis_file_protocol = gnc_uri_is_file_protocol( strs[i].protocol );
|
||||
testresult = ( tis_file_protocol == strs[i].is_file_protocol );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_is_file_protocol",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].uri, strs[i].is_file_protocol, tis_file_protocol );
|
||||
g_assert_true ( tis_file_protocol == strs[i].is_file_protocol );;
|
||||
}
|
||||
}
|
||||
|
||||
/* TEST: gnc_uri_is_file_uri */
|
||||
static void
|
||||
test_gnc_uri_is_file_uri()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; strs[i].uri != NULL; i++)
|
||||
{
|
||||
gboolean tis_file_uri;
|
||||
gboolean testresult;
|
||||
|
||||
tis_file_uri = gnc_uri_is_file_uri( strs[i].uri );
|
||||
testresult = ( tis_file_uri == strs[i].is_file_protocol );
|
||||
do_test_args(testresult,
|
||||
"gnc_uri_is_file_uri",
|
||||
__FILE__, __LINE__,
|
||||
"\n %s:\n"
|
||||
" Expected: %s\n"
|
||||
" Got : %s\n",
|
||||
strs[i].uri, strs[i].is_file_protocol, tis_file_uri );
|
||||
g_assert_true ( tis_file_uri == strs[i].is_file_protocol );
|
||||
}
|
||||
}
|
||||
|
||||
print_test_results();
|
||||
return get_rv();
|
||||
void
|
||||
test_suite_gnc_uri_utils(void)
|
||||
{
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_components()", test_gnc_uri_get_components);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_protocol()", test_gnc_uri_get_protocol);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_get_path()", test_gnc_uri_get_path);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_create_uri()", test_gnc_uri_create_uri);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_normalize_uri()", test_gnc_uri_normalize_uri);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_is_file_protocol()", test_gnc_uri_is_file_protocol);
|
||||
GNC_TEST_ADD_FUNC(suitename, "gnc_uri_is_file_uri()", test_gnc_uri_is_file_uri);
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ extern "C"
|
||||
#include <glib.h>
|
||||
#include <unittest-support.h>
|
||||
#include <gnc-event.h>
|
||||
#include <gnc-gdate-utils.h>
|
||||
#include <gnc-date.h>
|
||||
#include <qofinstance-p.h>
|
||||
/* Add specific headers for this class */
|
||||
#include "../Account.h"
|
||||
|
@ -1354,8 +1354,28 @@ GDate* gnc_g_date_new_today ()
|
||||
auto result = g_date_new_dmy (ymd.day, month, ymd.year);
|
||||
g_assert(g_date_valid (result));
|
||||
return result;
|
||||
}void
|
||||
|
||||
gnc_gdate_set_today (GDate* gd)
|
||||
{
|
||||
GDate *today = gnc_g_date_new_today ();
|
||||
g_date_set_julian (gd, g_date_get_julian (today));
|
||||
g_date_free (today);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_gdate_set_time64 (GDate* gd, time64 time)
|
||||
{
|
||||
struct tm tm;
|
||||
gnc_localtime_r(&time, &tm);
|
||||
g_date_set_dmy (gd, tm.tm_mday,
|
||||
static_cast<GDateMonth>(tm.tm_mon + 1),
|
||||
tm.tm_year + 1900);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Timespec gdate_to_timespec (GDate d)
|
||||
{
|
||||
return gnc_dmy2timespec_neutral (g_date_get_day(&d),
|
||||
|
@ -259,18 +259,32 @@ gboolean gnc_date_string_to_monthformat(const gchar *format_string,
|
||||
GNCDateMonthFormat *format);
|
||||
|
||||
/** \brief print a time64 as a date string per format
|
||||
* \param time
|
||||
* \param time The time64 to print
|
||||
* \param format A date format conforming to the strftime format rules.
|
||||
* \return a raw heap-allocated char* which must be freed.
|
||||
*/
|
||||
char* gnc_print_time64(time64 time, const char* format);
|
||||
|
||||
// @}
|
||||
|
||||
/** @name GDate time64 setters
|
||||
* @{ */
|
||||
/** Returns a newly allocated date of the current clock time, taken from
|
||||
* time(2). The caller must g_date_free() the object afterwards. */
|
||||
GDate* gnc_g_date_new_today (void);
|
||||
|
||||
/** Set a GDate to the current day
|
||||
* @param gd The date to act on
|
||||
*/
|
||||
void gnc_gdate_set_today (GDate* gd);
|
||||
|
||||
// @}
|
||||
/** Set a GDate to a time64
|
||||
* @param gd the date to act on
|
||||
* @param time the time to set it to.
|
||||
*/
|
||||
void gnc_gdate_set_time64 (GDate* gd, time64 time);
|
||||
|
||||
/** @} */
|
||||
|
||||
/* Datatypes *******************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user