diff --git a/lib/mu-date.c b/lib/mu-date.c index 280b0678..053524aa 100644 --- a/lib/mu-date.c +++ b/lib/mu-date.c @@ -83,205 +83,3 @@ mu_date_display_s (time_t t) else return mu_date_str_s ("%X", t); } - - - -time_t -mu_date_parse_hdwmy (const char *nptr) -{ - long int num; - char *endptr; - time_t now, delta; - time_t never = (time_t)-1; - - g_return_val_if_fail (nptr, never); - - num = strtol (nptr, &endptr, 10); - if (num <= 0 || num > 9999) - return never; - - if (endptr == NULL || *endptr == '\0') - return never; - - switch (endptr[0]) { - case 'h': /* hour */ - case 'H': - delta = num * 60 * 60; break; - case 'd': /* day */ - case 'D': - delta = num * 24 * 60 * 60; break; - case 'w': /* week */ - case 'W': - delta = num * 7 * 24 * 60 * 60; break; - case 'm': /* month */ - case 'M': - delta = num * 30 * 24 * 60 * 60; break; - case 'y': /* year */ - case 'Y': - delta = num * 365 * 24 * 60 * 60; break; - default: - return never; - } - - now = time(NULL); - return delta <= now ? now - delta : never; -} - - -/* clear a date of anything non-numberic; static string, non-reentrant */ -static char* -clear_date_s (const char *date) -{ - static char cleandate [14 + 1]; - unsigned u1, u2; - - for (u1 = u2 = 0; date[u1] != '\0'; ++u1) - if (isdigit(date[u1])) - cleandate[u2++] = date[u1]; - - cleandate[u2] = '\0'; - - return cleandate; -} - - - -const char* -mu_date_complete_s (const char *date, gboolean is_begin) -{ - static char fulldate[14 + 1]; - static const char* full_begin = "00000101000000"; - static const char* full_end = "99991231235959"; - - char *cleardate; - - g_return_val_if_fail (date, NULL); - - cleardate = clear_date_s (date); - - strncpy (fulldate, is_begin ? full_begin : full_end, - sizeof(fulldate)); - memcpy (fulldate, cleardate, strlen(cleardate)); - - return fulldate; -} - - -char* -mu_date_complete (const char *date, gboolean is_begin) -{ - const char *s; - - g_return_val_if_fail (date, NULL); - - s = mu_date_complete_s (date, is_begin); - return s ? g_strdup (s) : NULL; -} - - -const char* -mu_date_interpret_s (const char *datespec, gboolean is_begin) -{ - static char fulldate[14 + 1]; - time_t now, t; - - g_return_val_if_fail (datespec, NULL); - - if (mu_str_is_empty (datespec) && is_begin) - return "000000000000"; /* beginning of time*/ - - now = time(NULL); - if (strcmp (datespec, "today") == 0) { - strftime(fulldate, sizeof(fulldate), - is_begin ? "%Y%m%d000000" : "%Y%m%d235959", - localtime(&now)); - return fulldate; - } - - if (mu_str_is_empty (datespec) || strcmp (datespec, "now") == 0) { - strftime(fulldate, sizeof(fulldate), "%Y%m%d%H%M%S", - localtime(&now)); - return fulldate; - } - - t = mu_date_parse_hdwmy (datespec); - if (t != (time_t)-1) { - strftime(fulldate, sizeof(fulldate), "%Y%m%d%H%M%S", - localtime(&t)); - return fulldate; - } - - return datespec; /* nothing changed */ -} - - -char* -mu_date_interpret (const char *datespec, gboolean is_begin) -{ - char *s; - - g_return_val_if_fail (datespec, NULL); - - s = mu_date_interpret (datespec, is_begin); - return s ? g_strdup(s) : NULL; -} - - -time_t -mu_date_str_to_time_t (const char* date, gboolean local) -{ - struct tm tm; - char mydate[14 + 1]; /* YYYYMMDDHHMMSS */ - time_t t; - - memset (&tm, 0, sizeof(struct tm)); - strncpy (mydate, date, 15); - mydate[sizeof(mydate)-1] = '\0'; - - g_return_val_if_fail (date, (time_t)-1); - - tm.tm_sec = atoi (mydate + 12); mydate[12] = '\0'; - tm.tm_min = atoi (mydate + 10); mydate[10] = '\0'; - tm.tm_hour = atoi (mydate + 8); mydate[8] = '\0'; - tm.tm_mday = atoi (mydate + 6); mydate[6] = '\0'; - tm.tm_mon = atoi (mydate + 4) - 1; mydate[4] = '\0'; - tm.tm_year = atoi (mydate) - 1900; - tm.tm_isdst = -1; - /* let timegm/mktime figure out the dst */ - - if (local) - t = mktime (&tm); - else - t = timegm (&tm); /* GNU/BSD specific */ - - return t; -} - -const char* -mu_date_time_t_to_str_s (time_t t, gboolean local) -{ - /* static char datestr[14 + 1]; /\* YYYYMMDDHHMMSS *\/ */ - static char datestr[14+1]; /* YYYYMMDDHHMMSS */ - static const char *frm = "%Y%m%d%H%M%S"; - size_t len; - - len = strftime (datestr, sizeof(datestr), frm, - local ? localtime (&t) : gmtime(&t)); - if (len == 0) { - g_warning ("bug: error converting time"); - return "00000000000000"; - } - - return datestr; -} - - -char* -mu_date_time_t_to_str (time_t t, gboolean local) -{ - const char* str; - - str = mu_date_time_t_to_str_s (t, local); - - return str ? g_strdup(str): NULL; -} diff --git a/lib/mu-date.h b/lib/mu-date.h index 6d17517d..53df33be 100644 --- a/lib/mu-date.h +++ b/lib/mu-date.h @@ -24,6 +24,7 @@ G_BEGIN_DECLS + /** * @addtogroup MuDate * Date-related functions @@ -48,8 +49,6 @@ G_BEGIN_DECLS const char* mu_date_str_s (const char* frm, time_t t) G_GNUC_CONST; char* mu_date_str (const char* frm, time_t t) G_GNUC_WARN_UNUSED_RESULT; - - /** * get a display string for a given time_t; if the given is less than * 24h from the current time, we display the time, otherwise the date, @@ -63,90 +62,6 @@ char* mu_date_str (const char* frm, time_t t) G_GNUC_WARN_UNUSED_RESULT; */ const char* mu_date_display_s (time_t t); -/** - * - * parse strings like 1h, 3w, 2m to mean '1 hour before now', '3 weeks - * before now' and '2 * 30 days before now' - * - * the format is (h|d|w|m|y), where is an integer > 0, and - * h=hour, d=day, w=week, m=30 days, year=365 days. function returns - * *now* minus this value as time_t (UTC) - * - * if the number cannot be parsed, return (time_t)-1 - * - * @param str a str - * - * @return the time_t of the point in time indicated by 'now' minus - * the value, or (time_t)-1 otherwise - */ -time_t mu_date_parse_hdwmy (const char* str); - - - -/** - * complete a date (a string of the form YYYYMMDDHHMMSS with [0..14] - * of the rightmost characters missing) to the the full YYYYMMDDHHMMSS. - * - * if is_begin is TRUE, add to the 'floor' (e.g, - * 20110101=>20110101000000), otherwise go to the 'ceiling', - * e.g. 2009=>20091231235050) - * - * @param date a date string (assumed to have the beginning of the - * date, this is not checked - * @param is_begin if TRUE go to floor (as described), otherwise to - * the ceiling - * - * @return mu_date_complete: return a newly allocated string (free - * with g_free) with the full, 14-char date; mu_date_complete_s: - * return a statically allocated string. NOT REENTRANT. - */ -char* mu_date_complete (const char *date, gboolean is_begin); -const char* mu_date_complete_s (const char *date, gboolean is_begin); - - - -/** - * - * - * @param datespec - * @param is_begin - * - * @return - */ -const char* mu_date_interpret_s (const char *datespec, gboolean is_begin); -char* mu_date_interpret (const char *datespec, gboolean is_begin); - - - -/** - * convert a date of the form 'YYYYMMDDHHMMSS' into time_t - * - * @param date a date str of the form 'YYYYMMDDHHMMSS' - * @param local if TRUE, source is assumed to bin in local time, UTC otherwise - * - * @return the corresponding time_t, or (time_t)-1 in case of error - */ -time_t mu_date_str_to_time_t (const char* date, gboolean local); - - - - -/** - * convert a time_t value into a date string of the form - * 'YYYYMMDDHHMMSS'; assume UTC - * - * @param t a time_t value - * @param local if TRUE, convert to local time, otherwise use UTC - * - * @return mu_date_time_t_to_str_s: a static string (don't modify, - * non-reentrant) of the form 'YYYYMMDDHHMMSS'; mu_date_time_t_to_str: - * return a newly allocated string with the same. - */ -const char* mu_date_time_t_to_str_s (time_t t, gboolean local); -char* mu_date_time_t_to_str (time_t t, gboolean local); - -/** @} */ - G_END_DECLS #endif /*__MU_DATE_H__*/ diff --git a/lib/mu-util.c b/lib/mu-util.c index cac5a4a9..a25e145e 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -249,31 +249,6 @@ mu_util_create_dir_maybe (const gchar *path, mode_t mode, gboolean nowarn) } -gchar* -mu_util_str_from_strv (const gchar **params) -{ - GString *str; - int i; - - g_return_val_if_fail (params, NULL); - - if (!params[0]) - return g_strdup (""); - - str = g_string_sized_new (64); /* just a guess */ - - for (i = 0; params[i]; ++i) { - - if (i > 0) - g_string_append_c (str, ' '); - - g_string_append (str, params[i]); - } - - return g_string_free (str, FALSE); -} - - int mu_util_create_writeable_fd (const char* path, mode_t mode, gboolean overwrite) diff --git a/lib/mu-util.h b/lib/mu-util.h index c51f7c6c..fb891edf 100644 --- a/lib/mu-util.h +++ b/lib/mu-util.h @@ -109,8 +109,6 @@ gboolean mu_util_check_dir (const gchar* path, gboolean readable, */ const char* mu_util_cache_dir (void) G_GNUC_CONST; - - /** * create a writeable file and return its file descriptor (which * you'll need to close(2) when done with it.) @@ -246,17 +244,6 @@ GQuark mu_util_error_quark (void) G_GNUC_CONST; #define MU_ERROR_DOMAIN (mu_util_error_quark()) -/** - * convert a string array in to a string, with the elements separated - * by ' ' - * - * @param params a non-NULL, NULL-terminated string array - * - * @return a newly allocated string - */ -gchar* mu_util_str_from_strv (const gchar **params) -G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; - /* * for OSs with out support for direntry->d_type, like Solaris */ diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index d793fc4d..eb468da7 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am @@ -62,10 +62,6 @@ TEST_PROGS += test-mu-store test_mu_store_SOURCES= test-mu-store.c dummy.cc test_mu_store_LDADD= libtestmucommon.la -TEST_PROGS += test-mu-date -test_mu_date_SOURCES= test-mu-date.c dummy.cc -test_mu_date_LDADD= libtestmucommon.la - TEST_PROGS += test-mu-flags test_mu_flags_SOURCES= test-mu-flags.c dummy.cc test_mu_flags_LDADD= libtestmucommon.la @@ -75,14 +71,14 @@ test_mu_container_SOURCES= test-mu-container.c dummy.cc test_mu_container_LDADD= libtestmucommon.la # we need to use dummy.cc to enforce c++ linking... -BUILT_SOURCES= \ +BUILT_SOURCES= \ dummy.cc dummy.cc: touch dummy.cc -libtestmucommon_la_SOURCES= \ - test-mu-common.c \ +libtestmucommon_la_SOURCES= \ + test-mu-common.c \ test-mu-common.h libtestmucommon_la_LIBADD= ../libmu.la @@ -93,72 +89,72 @@ libtestmucommon_la_LIBADD= ../libmu.la # test messages, the '.ignore' message should be ignored # when indexing -EXTRA_DIST= \ - testdir/tmp/1220863087.12663.ignore \ - testdir/new/1220863087.12663_9.mindcrime \ - testdir/new/1220863087.12663_25.mindcrime \ - testdir/new/1220863087.12663_21.mindcrime \ - testdir/new/1220863087.12663_23.mindcrime \ - testdir/cur/1220863087.12663_5.mindcrime!2,S \ - testdir/cur/1220863087.12663_7.mindcrime!2,RS \ - testdir/cur/1220863087.12663_15.mindcrime!2,PS \ - testdir/cur/1220863087.12663_19.mindcrime!2,S \ - testdir/cur/1220863042.12663_1.mindcrime!2,S \ - testdir/cur/1220863060.12663_3.mindcrime!2,S \ - testdir/cur/1283599333.1840_11.cthulhu!2, \ - testdir/cur/1305664394.2171_402.cthulhu!2, \ - testdir/cur/1252168370_3.14675.cthulhu!2,S \ - testdir/cur/encrypted!2,S \ - testdir/cur/multimime!2,FS \ - testdir/cur/signed!2,S \ - testdir/cur/signed-encrypted!2,S \ - testdir/cur/special!2,Sabc \ - testdir/cur/multirecip!2,S \ - testdir2/bar/cur/mail1 \ - testdir2/bar/cur/mail2 \ - testdir2/bar/cur/mail3 \ - testdir2/bar/cur/mail4 \ - testdir2/bar/cur/mail5 \ - testdir2/bar/cur/181736.eml \ - testdir2/bar/cur/mail6 \ - testdir2/bar/tmp/.noindex \ - testdir2/bar/new/.noindex \ - testdir2/Foo/cur/mail5 \ - testdir2/Foo/cur/arto.eml \ - testdir2/Foo/cur/fraiche.eml \ - testdir2/Foo/tmp/.noindex \ - testdir2/Foo/new/.noindex \ - testdir2/wom_bat/cur/atomic \ - testdir2/wom_bat/cur/rfc822.1 \ - testdir2/wom_bat/cur/rfc822.2 \ - testdir3/cycle \ - testdir3/cycle/new/.noindex \ - testdir3/cycle/cur/rogue0 \ - testdir3/cycle/cur/cycle0 \ - testdir3/cycle/cur/cycle0.0 \ - testdir3/cycle/cur/cycle0.0.0 \ - testdir3/cycle/tmp/.noindex \ - testdir3/tree/new/.noindex \ - testdir3/tree/cur/child0.0 \ - testdir3/tree/cur/child4.0 \ - testdir3/tree/cur/root2 \ - testdir3/tree/cur/root1 \ - testdir3/tree/cur/child3.0.0.0.0 \ - testdir3/tree/cur/root0 \ - testdir3/tree/cur/child2.0.0 \ - testdir3/tree/cur/child0.1 \ - testdir3/tree/cur/child0.1.0 \ - testdir3/tree/cur/child4.1 \ - testdir3/tree/tmp/.noindex \ - testdir3/sort/1st-child-promotes-thread/cur/A \ - testdir3/sort/1st-child-promotes-thread/cur/B \ - testdir3/sort/1st-child-promotes-thread/cur/C \ - testdir3/sort/1st-child-promotes-thread/cur/D \ - testdir3/sort/2nd-child-promotes-thread/cur/A \ - testdir3/sort/2nd-child-promotes-thread/cur/B \ - testdir3/sort/2nd-child-promotes-thread/cur/C \ - testdir3/sort/2nd-child-promotes-thread/cur/D \ - testdir3/sort/2nd-child-promotes-thread/cur/E \ +EXTRA_DIST= \ + testdir/tmp/1220863087.12663.ignore \ + testdir/new/1220863087.12663_9.mindcrime \ + testdir/new/1220863087.12663_25.mindcrime \ + testdir/new/1220863087.12663_21.mindcrime \ + testdir/new/1220863087.12663_23.mindcrime \ + testdir/cur/1220863087.12663_5.mindcrime!2,S \ + testdir/cur/1220863087.12663_7.mindcrime!2,RS \ + testdir/cur/1220863087.12663_15.mindcrime!2,PS \ + testdir/cur/1220863087.12663_19.mindcrime!2,S \ + testdir/cur/1220863042.12663_1.mindcrime!2,S \ + testdir/cur/1220863060.12663_3.mindcrime!2,S \ + testdir/cur/1283599333.1840_11.cthulhu!2, \ + testdir/cur/1305664394.2171_402.cthulhu!2, \ + testdir/cur/1252168370_3.14675.cthulhu!2,S \ + testdir/cur/encrypted!2,S \ + testdir/cur/multimime!2,FS \ + testdir/cur/signed!2,S \ + testdir/cur/signed-encrypted!2,S \ + testdir/cur/special!2,Sabc \ + testdir/cur/multirecip!2,S \ + testdir2/bar/cur/mail1 \ + testdir2/bar/cur/mail2 \ + testdir2/bar/cur/mail3 \ + testdir2/bar/cur/mail4 \ + testdir2/bar/cur/mail5 \ + testdir2/bar/cur/181736.eml \ + testdir2/bar/cur/mail6 \ + testdir2/bar/tmp/.noindex \ + testdir2/bar/new/.noindex \ + testdir2/Foo/cur/mail5 \ + testdir2/Foo/cur/arto.eml \ + testdir2/Foo/cur/fraiche.eml \ + testdir2/Foo/tmp/.noindex \ + testdir2/Foo/new/.noindex \ + testdir2/wom_bat/cur/atomic \ + testdir2/wom_bat/cur/rfc822.1 \ + testdir2/wom_bat/cur/rfc822.2 \ + testdir3/cycle \ + testdir3/cycle/new/.noindex \ + testdir3/cycle/cur/rogue0 \ + testdir3/cycle/cur/cycle0 \ + testdir3/cycle/cur/cycle0.0 \ + testdir3/cycle/cur/cycle0.0.0 \ + testdir3/cycle/tmp/.noindex \ + testdir3/tree/new/.noindex \ + testdir3/tree/cur/child0.0 \ + testdir3/tree/cur/child4.0 \ + testdir3/tree/cur/root2 \ + testdir3/tree/cur/root1 \ + testdir3/tree/cur/child3.0.0.0.0 \ + testdir3/tree/cur/root0 \ + testdir3/tree/cur/child2.0.0 \ + testdir3/tree/cur/child0.1 \ + testdir3/tree/cur/child0.1.0 \ + testdir3/tree/cur/child4.1 \ + testdir3/tree/tmp/.noindex \ + testdir3/sort/1st-child-promotes-thread/cur/A \ + testdir3/sort/1st-child-promotes-thread/cur/B \ + testdir3/sort/1st-child-promotes-thread/cur/C \ + testdir3/sort/1st-child-promotes-thread/cur/D \ + testdir3/sort/2nd-child-promotes-thread/cur/A \ + testdir3/sort/2nd-child-promotes-thread/cur/B \ + testdir3/sort/2nd-child-promotes-thread/cur/C \ + testdir3/sort/2nd-child-promotes-thread/cur/D \ + testdir3/sort/2nd-child-promotes-thread/cur/E \ testdir3/sort/child-does-not-promote-thread/cur/A \ testdir3/sort/child-does-not-promote-thread/cur/X \ testdir3/sort/child-does-not-promote-thread/cur/Y \ @@ -170,22 +166,22 @@ EXTRA_DIST= \ testdir3/sort/grandchild-promotes-only-subthread/cur/E \ testdir3/sort/grandchild-promotes-only-subthread/cur/F \ testdir3/sort/grandchild-promotes-only-subthread/cur/G \ - testdir3/sort/grandchild-promotes-thread/cur/A \ - testdir3/sort/grandchild-promotes-thread/cur/B \ - testdir3/sort/grandchild-promotes-thread/cur/C \ - testdir3/sort/grandchild-promotes-thread/cur/D \ - testdir3/sort/grandchild-promotes-thread/cur/E \ - testdir4/1220863087.12663_19.mindcrime!2,S \ - testdir4/1220863042.12663_1.mindcrime!2,S \ - testdir4/1283599333.1840_11.cthulhu!2, \ - testdir4/1305664394.2171_402.cthulhu!2, \ - testdir4/1252168370_3.14675.cthulhu!2,S \ - testdir4/mail1 \ - testdir4/mail5 \ - testdir4/181736.eml \ - testdir4/encrypted!2,S \ - testdir4/multimime!2,FS \ - testdir4/signed!2,S \ - testdir4/signed-bad!2,S \ - testdir4/signed-encrypted!2,S \ + testdir3/sort/grandchild-promotes-thread/cur/A \ + testdir3/sort/grandchild-promotes-thread/cur/B \ + testdir3/sort/grandchild-promotes-thread/cur/C \ + testdir3/sort/grandchild-promotes-thread/cur/D \ + testdir3/sort/grandchild-promotes-thread/cur/E \ + testdir4/1220863087.12663_19.mindcrime!2,S \ + testdir4/1220863042.12663_1.mindcrime!2,S \ + testdir4/1283599333.1840_11.cthulhu!2, \ + testdir4/1305664394.2171_402.cthulhu!2, \ + testdir4/1252168370_3.14675.cthulhu!2,S \ + testdir4/mail1 \ + testdir4/mail5 \ + testdir4/181736.eml \ + testdir4/encrypted!2,S \ + testdir4/multimime!2,FS \ + testdir4/signed!2,S \ + testdir4/signed-bad!2,S \ + testdir4/signed-encrypted!2,S \ testdir4/special!2,Sabc diff --git a/lib/tests/test-mu-date.c b/lib/tests/test-mu-date.c index 6dfa3f1e..5cb6d5fa 100644 --- a/lib/tests/test-mu-date.c +++ b/lib/tests/test-mu-date.c @@ -34,113 +34,6 @@ #include "mu-date.h" -static void -test_mu_date_str (void) -{ - struct tm *tmbuf; - char buf[64]; - gchar *tmp; - time_t some_time; - - some_time = 1234567890; - tmbuf = localtime (&some_time); - strftime (buf, 64, "%x", tmbuf); - - /* $ date -ud@1234567890; Fri Feb 13 23:31:30 UTC 2009 */ - g_assert_cmpstr (mu_date_str_s ("%x", some_time), ==, buf); - - /* date -ud@987654321 Thu Apr 19 04:25:21 UTC 2001 */ - some_time = 987654321; - tmbuf = localtime (&some_time); - strftime (buf, 64, "%c", tmbuf); - tmp = mu_date_str ("%c", some_time); - - g_assert_cmpstr (tmp, ==, buf); - g_free (tmp); -} - - - -static void -test_mu_date_parse_hdwmy (void) -{ - time_t diff; - - diff = time(NULL) - mu_date_parse_hdwmy ("3h"); - g_assert (diff > 0); - g_assert_cmpuint (3 * 60 * 60 - diff, <=, 1); - - diff = time(NULL) - mu_date_parse_hdwmy ("5y"); - g_assert (diff > 0); - g_assert_cmpuint (5 * 365 * 24 * 60 * 60 - diff, <=, 1); - - diff = time(NULL) - mu_date_parse_hdwmy ("3m"); - g_assert (diff > 0); - g_assert_cmpuint (3 * 30 * 24 * 60 * 60 - diff, <=, 1); - - diff = time(NULL) - mu_date_parse_hdwmy ("21d"); - g_assert (diff > 0); - g_assert_cmpuint (21 * 24 * 60 * 60 - diff, <=, 1); - - diff = time(NULL) - mu_date_parse_hdwmy ("2w"); - g_assert (diff > 0); - g_assert_cmpuint (2 * 7 * 24 * 60 * 60 - diff, <=, 1); - - - g_assert_cmpint (mu_date_parse_hdwmy("-1y"),==, (time_t)-1); -} - - -static void -test_mu_date_complete_begin (void) -{ - g_assert_cmpstr (mu_date_complete_s("2000", TRUE), ==, - "20000101000000"); - g_assert_cmpstr (mu_date_complete_s("2", TRUE), ==, - "20000101000000"); - g_assert_cmpstr (mu_date_complete_s ("", TRUE), ==, - "00000101000000"); - g_assert_cmpstr (mu_date_complete_s ("201007", TRUE), ==, - "20100701000000"); - g_assert_cmpstr (mu_date_complete_s ("19721214", TRUE), ==, - "19721214000000"); - g_assert_cmpstr (mu_date_complete_s ("19721214234512", TRUE), ==, - "19721214234512"); - - g_assert_cmpstr (mu_date_complete_s ("2010-07", TRUE), ==, - "20100701000000"); - g_assert_cmpstr (mu_date_complete_s ("1972/12/14", TRUE), ==, - "19721214000000"); - g_assert_cmpstr (mu_date_complete_s ("1972-12-14 23:45:12", TRUE), ==, - "19721214234512"); - -} - - -static void -test_mu_date_complete_end (void) -{ - g_assert_cmpstr (mu_date_complete_s ("2000", FALSE), ==, - "20001231235959"); - g_assert_cmpstr (mu_date_complete_s ("2", FALSE), ==, - "29991231235959"); - g_assert_cmpstr (mu_date_complete_s ("", FALSE), ==, - "99991231235959"); - g_assert_cmpstr (mu_date_complete_s ("201007", FALSE), ==, - "20100731235959"); - g_assert_cmpstr (mu_date_complete_s ("19721214", FALSE), ==, - "19721214235959"); - g_assert_cmpstr (mu_date_complete_s ("19721214234512", FALSE), ==, - "19721214234512"); - - g_assert_cmpstr (mu_date_complete_s ("2010-07", FALSE), ==, - "20100731235959"); - g_assert_cmpstr (mu_date_complete_s ("1972.12.14", FALSE), ==, - "19721214235959"); - g_assert_cmpstr (mu_date_complete_s ("1972.12.14 23:45/12", FALSE), ==, - "19721214234512"); -} - @@ -179,10 +72,6 @@ main (int argc, char *argv[]) { g_test_init (&argc, &argv, NULL); - /* mu_str_date */ - g_test_add_func ("/mu-str/mu-date-str", - test_mu_date_str); - g_test_add_func ("/mu-str/mu_date_parse_hdwmy", test_mu_date_parse_hdwmy); g_test_add_func ("/mu-str/mu_date_complete_begin", diff --git a/lib/tests/test-mu-util.c b/lib/tests/test-mu-util.c index f63f2485..7986aeb0 100644 --- a/lib/tests/test-mu-util.c +++ b/lib/tests/test-mu-util.c @@ -56,7 +56,7 @@ test_mu_util_dir_expand_01 (void) * work. Turn of the test for now */ return; - + #ifdef HAVE_WORDEXP_H { gchar *got, *expected; @@ -162,37 +162,6 @@ test_mu_util_check_dir_04 (void) FALSE); } - -static void -test_mu_util_str_from_strv_01 (void) -{ - const gchar *strv[] = { "aap", "noot", "mies", NULL }; - gchar *str = mu_util_str_from_strv (strv); - g_assert_cmpstr (str, ==, "aap noot mies"); - g_free (str); - -} - -static void -test_mu_util_str_from_strv_02 (void) -{ - const gchar *strv[] = { "test", NULL }; - gchar *str = mu_util_str_from_strv (strv); - g_assert_cmpstr (str, ==, "test"); - g_free (str); - -} - -static void -test_mu_util_str_from_strv_03 (void) -{ - const gchar *strv[] = { NULL }; - gchar *str = mu_util_str_from_strv (strv); - g_assert_cmpstr (str, ==, ""); - g_free (str); -} - - static void test_mu_util_get_dtype_with_lstat (void) { @@ -223,10 +192,12 @@ test_mu_util_supports (void) path = g_find_program_in_path ("gnuplot"); g_free (path); - g_assert_cmpuint (mu_util_supports (MU_FEATURE_GNUPLOT),==,path ? TRUE : FALSE); + g_assert_cmpuint (mu_util_supports (MU_FEATURE_GNUPLOT),==, + path ? TRUE : FALSE); g_assert_cmpuint ( - mu_util_supports (MU_FEATURE_GNUPLOT|MU_FEATURE_GUILE|MU_FEATURE_CRYPTO), + mu_util_supports (MU_FEATURE_GNUPLOT|MU_FEATURE_GUILE| + MU_FEATURE_CRYPTO), ==, has_guile && path ? TRUE : FALSE); } @@ -246,8 +217,10 @@ main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); /* mu_util_dir_expand */ - g_test_add_func ("/mu-util/mu-util-dir-expand-00", test_mu_util_dir_expand_00); - g_test_add_func ("/mu-util/mu-util-dir-expand-01", test_mu_util_dir_expand_01); + g_test_add_func ("/mu-util/mu-util-dir-expand-00", + test_mu_util_dir_expand_00); + g_test_add_func ("/mu-util/mu-util-dir-expand-01", + test_mu_util_dir_expand_01); /* mu_util_guess_maildir */ g_test_add_func ("/mu-util/mu-util-guess-maildir-01", @@ -256,24 +229,21 @@ main (int argc, char *argv[]) test_mu_util_guess_maildir_02); /* mu_util_check_dir */ - g_test_add_func ("/mu-util/mu-util-check-dir-01", test_mu_util_check_dir_01); - g_test_add_func ("/mu-util/mu-util-check-dir-02", test_mu_util_check_dir_02); - g_test_add_func ("/mu-util/mu-util-check-dir-03", test_mu_util_check_dir_03); - g_test_add_func ("/mu-util/mu-util-check-dir-04", test_mu_util_check_dir_04); - - /* test_mu_util_str_from_strv */ - g_test_add_func ("/mu-util/mu-util-str-from-strv-01", - test_mu_util_str_from_strv_01); - g_test_add_func ("/mu-util/mu-util-str-from-strv-02", - test_mu_util_str_from_strv_02); - g_test_add_func ("/mu-util/mu-util-str-from-strv-03", - test_mu_util_str_from_strv_03); + g_test_add_func ("/mu-util/mu-util-check-dir-01", + test_mu_util_check_dir_01); + g_test_add_func ("/mu-util/mu-util-check-dir-02", + test_mu_util_check_dir_02); + g_test_add_func ("/mu-util/mu-util-check-dir-03", + test_mu_util_check_dir_03); + g_test_add_func ("/mu-util/mu-util-check-dir-04", + test_mu_util_check_dir_04); g_test_add_func ("/mu-util/mu-util-get-dtype-with-lstat", test_mu_util_get_dtype_with_lstat); g_test_add_func ("/mu-util/mu-util-supports", test_mu_util_supports); - g_test_add_func ("/mu-util/mu-util-program-in-path", test_mu_util_program_in_path); + g_test_add_func ("/mu-util/mu-util-program-in-path", + test_mu_util_program_in_path); g_log_set_handler (NULL,