r15375 - gnucash/branches/sx-cleanup/src - Bug#104844: unit test freqspec regarding monthly:31st handling. Fix gnc-frequency to use correct and valid dates for setting up the FreqSpec.
Josh Sled
jsled at cvs.gnucash.org
Sun Jan 14 12:39:11 EST 2007
Author: jsled
Date: 2007-01-14 12:39:11 -0500 (Sun, 14 Jan 2007)
New Revision: 15375
Trac: http://svn.gnucash.org/trac/changeset/15375
Modified:
gnucash/branches/sx-cleanup/src/doc/sx.rst
gnucash/branches/sx-cleanup/src/engine/test/test-freq-spec.c
gnucash/branches/sx-cleanup/src/gnome-utils/gnc-frequency.c
Log:
Bug#104844: unit test freqspec regarding monthly:31st handling. Fix gnc-frequency to use correct and valid dates for setting up the FreqSpec.
Modified: gnucash/branches/sx-cleanup/src/doc/sx.rst
===================================================================
--- gnucash/branches/sx-cleanup/src/doc/sx.rst 2007-01-14 16:41:36 UTC (rev 15374)
+++ gnucash/branches/sx-cleanup/src/doc/sx.rst 2007-01-14 17:39:11 UTC (rev 15375)
@@ -29,7 +29,7 @@
- [x] sx list collection add/remove -- sx-list GNC_EVENT_ITEM_ADDED, _REMOVED
- [x] sx modified -- QOF_EVENT_MODIFY
- [/] sx upcoming instance model
- - [ ] implement sort model
+! - [ ] implement sort model
- [x] rename, re-home gnc-sx-instance-model:sxsl_get_sx_vars
- [x] rename, re-home gnc-sx-instance-model:parse_vars_from_formula
@@ -51,10 +51,17 @@
- [ ] +autocreate, -notify, w/postponed
- [ ] +autocreate, +notify, w/postponed
- [ ] bugs
- - [ ] Scheduled Transactions on 31st/last put in following month - <http://bugzilla.gnome.org/show_bug.cgi?id=104844>
- - [ ] Expired scheduled transactions never run - <http://bugzilla.gnome.org/show_bug.cgi?id=375892>
- - [ ] With many auto-create transactions but none with notify option, "Auto-Created Transactions Notification" druid page lists every existing transaction - <http://bugzilla.gnome.org/show_bug.cgi?id=347116>
+ - [?] Expired scheduled transactions never run - <http://bugzilla.gnome.org/show_bug.cgi?id=375892>
+- bugs
+ - [ ] crash with two sx lists open and SX mutation [[[
+ (gnucash:17610): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GncSxListTreeModelAdapterType'
+ sx list tree model adapter update
+
+ (gnucash:17610): Gtk-CRITICAL **: gtk_tree_store_clear: assertion `GTK_IS_TREE_STORE (tree_store)' failed ]]]
+ - [ ] new file, monthly:31st, start=2/28/2007, create-in-advance=180; since-last-run, +review, Ok => no review.
+ - [x] Scheduled Transactions on 31st/last put in following month - <http://bugzilla.gnome.org/show_bug.cgi?id=104844>
+
- sx list page
- [/] make into split panel
- [ ] fix slider position
@@ -89,7 +96,7 @@
- [ ] XML migration, handling
- since-last-run
- - [ ] rewrite adapter (re-)population logic
+! - [ ] rewrite adapter (re-)population logic
- [x] move "effect_change" up to app-utils/, test.
- [x] move state-change up to app-utils
- [x] move variable-setting up to app-utils
@@ -239,7 +246,7 @@
Bugs to close after merge
--------------------------------------
-- Auto-Created Transactions Notification dialog shows MANY ... - http://bugzilla.gnome.org/show_bug.cgi?id=393381
+- With many auto-create transactions but none with notify option, "Auto-Created Transactions Notification" druid page lists every existing transaction - http://bugzilla.gnome.org/show_bug.cgi?id=347116
- Since last run dialog does not allow for early finish, an... - http://bugzilla.gnome.org/show_bug.cgi?id=329384
- Since Last Run druid changes data before Apply - http://bugzilla.gnome.org/show_bug.cgi?id=333849
- Resize the "Since Last Run" window is incorrect - http://bugzilla.gnome.org/show_bug.cgi?id=353563
@@ -248,3 +255,5 @@
- Scrolling through variables list does not work - http://bugzilla.gnome.org/show_bug.cgi?id=343190
- Gnucash thinks the file has changed after cancelling out of the Since Last Run dialog and making no changes - http://bugzilla.gnome.org/show_bug.cgi?id=344494
- Transaction reminder with variable amount doesn't display value field - http://bugzilla.gnome.org/show_bug.cgi?id=147946
+
+
Modified: gnucash/branches/sx-cleanup/src/engine/test/test-freq-spec.c
===================================================================
--- gnucash/branches/sx-cleanup/src/engine/test/test-freq-spec.c 2007-01-14 16:41:36 UTC (rev 15374)
+++ gnucash/branches/sx-cleanup/src/engine/test/test-freq-spec.c 2007-01-14 17:39:11 UTC (rev 15375)
@@ -559,6 +559,50 @@
xaccFreqSpecFree(fs);
}
+static void
+test_monthly_31st_bug_104844()
+{
+ gchar date_buf[128];
+ GDate start, next, expected;
+ FreqSpec *fs = xaccFreqSpecMalloc(book);
+
+ g_date_clear(&next, 1);
+
+ g_date_clear(&start, 1);
+ g_date_set_dmy(&start, 31, 1, 2003);
+ xaccFreqSpecSetMonthly(fs, &start, 1);
+
+ //g_date_add_days(&start, 1);
+ xaccFreqSpecGetNextInstance(fs, &start, &next);
+ g_date_clear(&expected, 1);
+ g_date_set_dmy(&expected, 28, 2, 2003);
+ g_date_strftime(date_buf, 128, "%c", &next);
+ do_test(g_date_compare(&expected, &next) == 0, date_buf);
+
+ start = next;
+ xaccFreqSpecGetNextInstance(fs, &start, &next);
+ g_date_set_dmy(&expected, 31, 3, 2003);
+ g_date_strftime(date_buf, 128, "%c", &next);
+ do_test(g_date_compare(&expected, &next) == 0, date_buf);
+
+ // test...
+ g_date_set_dmy(&start, 31, 1, 2003);
+ xaccFreqSpecSetMonthly(fs, &start, 1);
+ g_date_set_dmy(&start, 31, 1, 2007);
+ xaccFreqSpecGetNextInstance(fs, &start, &next);
+ g_date_set_dmy(&expected, 28, 2, 2007);
+ g_date_strftime(date_buf, 128, "%c", &next);
+ do_test(g_date_compare(&expected, &next) == 0, date_buf);
+
+ start = next;
+ xaccFreqSpecGetNextInstance(fs, &start, &next);
+ g_date_set_dmy(&expected, 31, 3, 2007);
+ g_date_strftime(date_buf, 128, "%c", &next);
+ do_test(g_date_compare(&expected, &next) == 0, date_buf);
+
+ xaccFreqSpecFree(fs);
+}
+
int
main (int argc, char **argv)
{
@@ -568,6 +612,9 @@
g_return_val_if_fail(cashobjects_register(), -1);
session = qof_session_new ();
book = qof_session_get_book(session);
+
+ test_monthly_31st_bug_104844();
+
test_once();
test_caseA();
test_daily();
@@ -575,6 +622,7 @@
test_monthly();
test_month_relative();
test_composite();
+
print_test_results();
qof_session_end(session);
qof_close();
Modified: gnucash/branches/sx-cleanup/src/gnome-utils/gnc-frequency.c
===================================================================
--- gnucash/branches/sx-cleanup/src/gnome-utils/gnc-frequency.c 2007-01-14 16:41:36 UTC (rev 15374)
+++ gnucash/branches/sx-cleanup/src/gnome-utils/gnc-frequency.c 2007-01-14 17:39:11 UTC (rev 15375)
@@ -791,15 +791,19 @@
}
case UIFREQ_MONTHLY:
{
- struct tm stm;
o = glade_xml_get_widget( gf->gxml, "monthly_spin" );
tmpInt = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(o));
- g_date_to_struct_tm( &gd, &stm);
o = glade_xml_get_widget( gf->gxml, "monthly_day" );
day = gnc_option_menu_get_active( GTK_WIDGET(o) ) + 1;
- stm.tm_mday = day;
- g_date_set_time_t( &gd, mktime( &stm ) );
+ g_date_set_time_t(&gd, time(NULL));
+ g_date_set_month(&gd, 1);
+ g_date_set_day(&gd, day);
+ {
+ gchar buf[128];
+ g_date_strftime(buf, 127, "%c", &gd);
+ printf("monthly date [%s]\n", buf);
+ }
xaccFreqSpecSetMonthly( fs, &gd, tmpInt );
xaccFreqSpecSetUIType( fs, uift );
break;
More information about the gnucash-changes
mailing list