GDate API Rename Patch #2
- From: Ali Abdin <aliabdin aucegypt edu>
- To: hp redhat com
- Cc: gtk-devel-list gnome org
- Subject: GDate API Rename Patch #2
- Date: Mon, 18 Dec 2000 01:57:32 -0200
Attached below is the patch for the rename of the GDate API to use the *_get_*
equivelants.
The difference between this one and before is that this now adds a gcompat.h
header file, simulated after the one found in Gtk+ (Per Havoc's request).
Regards,
Ali
? gislamicdate.h
? gdate-convert.pl
? gdate-api-update.diff
cvs server: Diffing .
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/Makefile.am,v
retrieving revision 1.70
diff -u -r1.70 Makefile.am
--- Makefile.am 2000/12/05 20:45:32 1.70
+++ Makefile.am 2000/12/17 18:46:51
@@ -8,7 +8,8 @@
BUILT_SOURCES=glib-config-2.0
glib-config-2.0: glib-config-2.0.in
-INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@
+INCLUDES = -DG_LOG_DOMAIN=g_log_domain_glib @GLIB_DEBUG_FLAGS@ \
+ -DG_DISBALE_COMPAT_H
EXTRA_DIST = \
ChangeLog.pre-1-2 \
@@ -101,6 +102,7 @@
gasyncqueue.h \
gbacktrace.h \
gcache.h \
+ gcompat.h \
gcompletion.h \
gconvert.h \
gdataset.h \
Index: gcompat.h
===================================================================
RCS file: gcompat.h
diff -N gcompat.h
--- /dev/null Tue May 5 16:32:27 1998
+++ gcompat.h Sun Dec 17 13:46:51 2000
@@ -0,0 +1,45 @@
+/* GLIB - Library of useful routines for C programming
+ *
+ * Copyright (C) 2000 Ali Abdin <aliabdin aucegypt edu>
+ *
+ * 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 Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __G_COMPAT_H__
+#define __G_COMPAT_H__
+
+#include <gmacros.h>
+
+G_BEGIN_DECLS
+
+#ifndef G_DISABLE_COMPAT_H
+
+#define g_date_weekday g_date_get_weekday
+#define g_date_month g_date_get_month
+#define g_date_year g_date_get_year
+#define g_date_day g_date_get_day
+#define g_date_julian g_date_get_julian
+#define g_date_day_of_year g_date_get_day_of_year
+#define g_date_monday_week_of_year g_date_get_monday_week_of_year
+#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year
+#define g_date_days_in_month g_date_get_days_in_month
+#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year
+#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year
+
+#endif /* G_DISABLE_COMPAT_H */
+
+G_END_DECLS
+
+#endif /* __G_COMPAT_H__ */
Index: gdate.c
===================================================================
RCS file: /cvs/gnome/glib/gdate.c,v
retrieving revision 1.20
diff -u -r1.20 gdate.c
--- gdate.c 2000/09/29 13:37:00 1.20
+++ gdate.c 2000/12/17 18:46:53
@@ -249,7 +249,7 @@
}
GDateWeekday
-g_date_weekday (GDate *d)
+g_date_get_weekday (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_WEEKDAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_WEEKDAY);
@@ -264,7 +264,7 @@
}
GDateMonth
-g_date_month (GDate *d)
+g_date_get_month (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_MONTH);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_MONTH);
@@ -279,7 +279,7 @@
}
GDateYear
-g_date_year (GDate *d)
+g_date_get_year (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_YEAR);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_YEAR);
@@ -294,7 +294,7 @@
}
GDateDay
-g_date_day (GDate *d)
+g_date_get_day (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_DAY);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_DAY);
@@ -309,7 +309,7 @@
}
guint32
-g_date_julian (GDate *d)
+g_date_get_julian (GDate *d)
{
g_return_val_if_fail (d != NULL, G_DATE_BAD_JULIAN);
g_return_val_if_fail (g_date_valid (d), G_DATE_BAD_JULIAN);
@@ -324,7 +324,7 @@
}
guint
-g_date_day_of_year (GDate *d)
+g_date_get_day_of_year (GDate *d)
{
gint index;
@@ -343,7 +343,7 @@
}
guint
-g_date_monday_week_of_year (GDate *d)
+g_date_get_monday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
@@ -362,14 +362,14 @@
g_date_set_dmy (&first, 1, 1, d->year);
- wd = g_date_weekday (&first) - 1; /* make Monday day 0 */
- day = g_date_day_of_year (d) - 1;
+ wd = g_date_get_weekday (&first) - 1; /* make Monday day 0 */
+ day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
guint
-g_date_sunday_week_of_year (GDate *d)
+g_date_get_sunday_week_of_year (GDate *d)
{
GDateWeekday wd;
guint day;
@@ -388,9 +388,9 @@
g_date_set_dmy (&first, 1, 1, d->year);
- wd = g_date_weekday (&first);
+ wd = g_date_get_weekday (&first);
if (wd == 7) wd = 0; /* make Sunday day 0 */
- day = g_date_day_of_year (d) - 1;
+ day = g_date_get_day_of_year (d) - 1;
return ((day + wd)/7U + (wd == 0 ? 1 : 0));
}
@@ -1119,8 +1119,8 @@
}
guint8
-g_date_days_in_month (GDateMonth month,
- GDateYear year)
+g_date_get_days_in_month (GDateMonth month,
+ GDateYear year)
{
gint index;
@@ -1133,7 +1133,7 @@
}
guint8
-g_date_monday_weeks_in_year (GDateYear year)
+g_date_get_monday_weeks_in_year (GDateYear year)
{
GDate d;
@@ -1141,21 +1141,21 @@
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
- if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
- if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
- if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
- if (g_date_weekday (&d) == G_DATE_MONDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_MONDAY) return 53;
}
return 52;
}
guint8
-g_date_sunday_weeks_in_year (GDateYear year)
+g_date_get_sunday_weeks_in_year (GDateYear year)
{
GDate d;
@@ -1163,15 +1163,15 @@
g_date_clear (&d, 1);
g_date_set_dmy (&d, 1, 1, year);
- if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 31, 12, year);
- if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
if (g_date_is_leap_year (year))
{
g_date_set_dmy (&d, 2, 1, year);
- if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
g_date_set_dmy (&d, 30, 12, year);
- if (g_date_weekday (&d) == G_DATE_SUNDAY) return 53;
+ if (g_date_get_weekday (&d) == G_DATE_SUNDAY) return 53;
}
return 52;
}
@@ -1257,12 +1257,12 @@
tm->tm_mon = d->month - 1; /* 0-11 goes in tm */
tm->tm_year = ((int)d->year) - 1900; /* X/Open says tm_year can be negative */
- day = g_date_weekday (d);
+ day = g_date_get_weekday (d);
if (day == 7) day = 0; /* struct tm wants days since Sunday, so Sunday is 0 */
tm->tm_wday = (int)day;
- tm->tm_yday = g_date_day_of_year (d) - 1; /* 0 to 365 */
+ tm->tm_yday = g_date_get_day_of_year (d) - 1; /* 0 to 365 */
tm->tm_isdst = -1; /* -1 means "information not available" */
}
Index: gdate.h
===================================================================
RCS file: /cvs/gnome/glib/gdate.h,v
retrieving revision 1.1
diff -u -r1.1 gdate.h
--- gdate.h 2000/10/12 11:52:07 1.1
+++ gdate.h 2000/12/17 18:46:53
@@ -136,20 +136,20 @@
GDateMonth month,
GDateYear year) G_GNUC_CONST;
-GDateWeekday g_date_weekday (GDate *date);
-GDateMonth g_date_month (GDate *date);
-GDateYear g_date_year (GDate *date);
-GDateDay g_date_day (GDate *date);
-guint32 g_date_julian (GDate *date);
-guint g_date_day_of_year (GDate *date);
+GDateWeekday g_date_get_weekday (GDate *date);
+GDateMonth g_date_get_month (GDate *date);
+GDateYear g_date_get_year (GDate *date);
+GDateDay g_date_get_day (GDate *date);
+guint32 g_date_get_julian (GDate *date);
+guint g_date_get_day_of_year (GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
* that day, return 0. These are not ISO weeks of the year; that
* routine needs to be added.
* these functions return the number of weeks, starting on the
* corrsponding day
*/
-guint g_date_monday_week_of_year (GDate *date);
-guint g_date_sunday_week_of_year (GDate *date);
+guint g_date_get_monday_week_of_year (GDate *date);
+guint g_date_get_sunday_week_of_year (GDate *date);
/* If you create a static date struct you need to clear it to get it
* in a sane state before use. You can clear a whole array at
@@ -199,10 +199,10 @@
void g_date_subtract_years (GDate *date,
guint n_years);
gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
-guint8 g_date_days_in_month (GDateMonth month,
+guint8 g_date_get_days_in_month (GDateMonth month,
GDateYear year) G_GNUC_CONST;
-guint8 g_date_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
-guint8 g_date_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
+guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
+guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
/* qsort-friendly (with a cast...) */
gint g_date_compare (GDate *lhs,
Index: glib.h
===================================================================
RCS file: /cvs/gnome/glib/glib.h,v
retrieving revision 1.212
diff -u -r1.212 glib.h
--- glib.h 2000/11/20 23:59:32 1.212
+++ glib.h 2000/12/17 18:46:54
@@ -32,6 +32,7 @@
#include <gasyncqueue.h>
#include <gbacktrace.h>
#include <gcache.h>
+#include <gcompat.h>
#include <gcompletion.h>
#include <gconvert.h>
#include <gdataset.h>
Index: testgdate.c
===================================================================
RCS file: /cvs/gnome/glib/testgdate.c,v
retrieving revision 1.2
diff -u -r1.2 testgdate.c
--- testgdate.c 2000/05/19 08:18:29 1.2
+++ testgdate.c 2000/12/17 18:46:55
@@ -80,13 +80,13 @@
TEST("January 1, Year 1 created and valid", g_date_valid(d));
- j = g_date_julian(d);
+ j = g_date_get_julian(d);
TEST("January 1, Year 1 is Julian date 1", j == 1);
- TEST("Returned month is January", g_date_month(d) == G_DATE_JANUARY);
- TEST("Returned day is 1", g_date_day(d) == 1);
- TEST("Returned year is 1", g_date_year(d) == 1);
+ TEST("Returned month is January", g_date_get_month(d) == G_DATE_JANUARY);
+ TEST("Returned day is 1", g_date_get_day(d) == 1);
+ TEST("Returned year is 1", g_date_get_year(d) == 1);
TEST("Bad month is invalid", !g_date_valid_month(G_DATE_BAD_MONTH));
TEST("Month 13 is invalid", !g_date_valid_month(13));
@@ -138,9 +138,9 @@
/* Note: this test will hopefully work, but no promises. */
TEST("Successfully parsed a %x-formatted string",
g_date_valid(d) &&
- g_date_month(d) == 1 &&
- g_date_day(d) == 10 &&
- g_date_year(d) == 2000);
+ g_date_get_month(d) == 1 &&
+ g_date_get_day(d) == 10 &&
+ g_date_get_year(d) == 2000);
if (failed)
g_date_debug_print(d);
@@ -157,9 +157,9 @@
guint32 first_day_of_year = G_DATE_BAD_JULIAN;
guint16 days_in_year = g_date_is_leap_year(y) ? 366 : 365;
guint sunday_week_of_year = 0;
- guint sunday_weeks_in_year = g_date_sunday_weeks_in_year(y);
+ guint sunday_weeks_in_year = g_date_get_sunday_weeks_in_year(y);
guint monday_week_of_year = 0;
- guint monday_weeks_in_year = g_date_monday_weeks_in_year(y);
+ guint monday_weeks_in_year = g_date_get_monday_weeks_in_year(y);
if (discontinuity)
g_print(" (Break in sequence of requested years to check)\n");
@@ -177,7 +177,7 @@
m = 1;
while (m < 13)
{
- guint8 dim = g_date_days_in_month(m,y);
+ guint8 dim = g_date_get_days_in_month(m,y);
GDate days[31]; /* This is the fast way, no allocation */
TEST("Sensible number of days in month", (dim > 0 && dim < 32));
@@ -207,89 +207,89 @@
if (m == G_DATE_JANUARY && day == 1)
{
- first_day_of_year = g_date_julian(d);
+ first_day_of_year = g_date_get_julian(d);
}
g_assert(first_day_of_year != G_DATE_BAD_JULIAN);
TEST("Date with DMY triplet is valid", g_date_valid(d));
- TEST("Month accessor works", g_date_month(d) == m);
- TEST("Year accessor works", g_date_year(d) == y);
- TEST("Day of month accessor works", g_date_day(d) == day);
+ TEST("Month accessor works", g_date_get_month(d) == m);
+ TEST("Year accessor works", g_date_get_year(d) == y);
+ TEST("Day of month accessor works", g_date_get_day(d) == day);
TEST("Day of year is consistent with Julian dates",
- ((g_date_julian(d) + 1 - first_day_of_year) ==
- (g_date_day_of_year(d))));
+ ((g_date_get_julian(d) + 1 - first_day_of_year) ==
+ (g_date_get_day_of_year(d))));
if (failed)
{
g_print("first day: %u this day: %u day of year: %u\n",
first_day_of_year,
- g_date_julian(d),
- g_date_day_of_year(d));
+ g_date_get_julian(d),
+ g_date_get_day_of_year(d));
}
if (m == G_DATE_DECEMBER && day == 31)
{
TEST("Last day of year equals number of days in year",
- g_date_day_of_year(d) == days_in_year);
+ g_date_get_day_of_year(d) == days_in_year);
if (failed)
{
g_print("last day: %u days in year: %u\n",
- g_date_day_of_year(d), days_in_year);
+ g_date_get_day_of_year(d), days_in_year);
}
}
TEST("Day of year is not more than number of days in the year",
- g_date_day_of_year(d) <= days_in_year);
+ g_date_get_day_of_year(d) <= days_in_year);
TEST("Monday week of year is not more than number of weeks in the year",
- g_date_monday_week_of_year(d) <= monday_weeks_in_year);
+ g_date_get_monday_week_of_year(d) <= monday_weeks_in_year);
if (failed)
{
g_print("Weeks in year: %u\n", monday_weeks_in_year);
g_date_debug_print(d);
}
TEST("Monday week of year is >= than last week of year",
- g_date_monday_week_of_year(d) >= monday_week_of_year);
+ g_date_get_monday_week_of_year(d) >= monday_week_of_year);
- if (g_date_weekday(d) == G_DATE_MONDAY)
+ if (g_date_get_weekday(d) == G_DATE_MONDAY)
{
TEST("Monday week of year on Monday 1 more than previous day's week of year",
- (g_date_monday_week_of_year(d) - monday_week_of_year) == 1);
+ (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 1);
}
else
{
TEST("Monday week of year on non-Monday 0 more than previous day's week of year",
- (g_date_monday_week_of_year(d) - monday_week_of_year) == 0);
+ (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 0);
}
- monday_week_of_year = g_date_monday_week_of_year(d);
+ monday_week_of_year = g_date_get_monday_week_of_year(d);
TEST("Sunday week of year is not more than number of weeks in the year",
- g_date_sunday_week_of_year(d) <= sunday_weeks_in_year);
+ g_date_get_sunday_week_of_year(d) <= sunday_weeks_in_year);
if (failed)
{
g_date_debug_print(d);
}
TEST("Sunday week of year is >= than last week of year",
- g_date_sunday_week_of_year(d) >= sunday_week_of_year);
+ g_date_get_sunday_week_of_year(d) >= sunday_week_of_year);
- if (g_date_weekday(d) == G_DATE_SUNDAY)
+ if (g_date_get_weekday(d) == G_DATE_SUNDAY)
{
TEST("Sunday week of year on Sunday 1 more than previous day's week of year",
- (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 1);
+ (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 1);
}
else
{
TEST("Sunday week of year on non-Sunday 0 more than previous day's week of year",
- (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 0);
+ (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 0);
}
- sunday_week_of_year = g_date_sunday_week_of_year(d);
+ sunday_week_of_year = g_date_get_sunday_week_of_year(d);
TEST("Date is equal to itself",
g_date_compare(d,d) == 0);
@@ -310,7 +310,7 @@
g_date_subtract_days(d, i);
TEST("Forward days then backward days returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -319,7 +319,7 @@
}
TEST("Forward days then backward days returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -328,7 +328,7 @@
}
TEST("Forward days then backward days returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -345,7 +345,7 @@
g_date_subtract_months(d, i);
TEST("Forward months then backward months returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -354,7 +354,7 @@
}
TEST("Forward months then backward months returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -368,7 +368,7 @@
/* Day should be unchanged */
TEST("Forward months then backward months returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -393,7 +393,7 @@
g_date_subtract_years(d, i);
TEST("Forward years then backward years returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -402,7 +402,7 @@
}
TEST("Forward years then backward years returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -413,7 +413,7 @@
if (m != 2 && day != 29)
{
TEST("Forward years then backward years returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -436,16 +436,16 @@
/* We can only run sequence tests between sequential years */
TEST("Julians are sequential with increment 1",
- j+1 == g_date_julian(d));
+ j+1 == g_date_get_julian(d));
if (failed)
{
g_print("Out of sequence, prev: %u expected: %u got: %u\n",
- j, j+1, g_date_julian(d));
+ j, j+1, g_date_get_julian(d));
}
g_date_add_days(d,1);
TEST("Next day has julian 1 higher",
- g_date_julian(d) == j + 2);
+ g_date_get_julian(d) == j + 2);
g_date_subtract_days(d, 1);
if (j != G_DATE_BAD_JULIAN)
@@ -453,7 +453,7 @@
g_date_subtract_days(d, 1);
TEST("Previous day has julian 1 lower",
- g_date_julian(d) == j);
+ g_date_get_julian(d) == j);
g_date_add_days(d, 1); /* back to original */
}
@@ -463,7 +463,7 @@
fflush(stdout);
fflush(stderr);
- j = g_date_julian(d); /* inc current julian */
+ j = g_date_get_julian(d); /* inc current julian */
++day;
}
cvs server: Diffing build
cvs server: Diffing build/win32
cvs server: Diffing debian
cvs server: Diffing docs
cvs server: Diffing docs/reference
cvs server: Diffing docs/reference/glib
Index: docs/reference/glib/glib-sections.txt
===================================================================
RCS file: /cvs/gnome/glib/docs/reference/glib/glib-sections.txt,v
retrieving revision 1.18
diff -u -r1.18 glib-sections.txt
--- docs/reference/glib/glib-sections.txt 2000/12/05 20:43:56 1.18
+++ docs/reference/glib/glib-sections.txt 2000/12/17 18:46:57
@@ -879,22 +879,22 @@
g_date_compare
<SUBSECTION>
-g_date_day
-g_date_month
-g_date_year
-g_date_julian
-g_date_weekday
-g_date_day_of_year
+g_date_get_day
+g_date_get_month
+g_date_get_year
+g_date_get_julian
+g_date_get_weekday
+g_date_get_day_of_year
<SUBSECTION>
-g_date_days_in_month
+g_date_get_days_in_month
g_date_is_first_of_month
g_date_is_last_of_month
g_date_is_leap_year
-g_date_monday_week_of_year
-g_date_monday_weeks_in_year
-g_date_sunday_week_of_year
-g_date_sunday_weeks_in_year
+g_date_get_monday_week_of_year
+g_date_get_monday_weeks_in_year
+g_date_get_sunday_week_of_year
+g_date_get_sunday_weeks_in_year
<SUBSECTION>
g_date_strftime
cvs server: Diffing docs/reference/glib/tmpl
cvs server: Diffing docs/reference/gobject
cvs server: Diffing docs/reference/gobject/tmpl
cvs server: Diffing gmodule
cvs server: Diffing gobject
cvs server: Diffing gthread
cvs server: Diffing tests
Index: tests/date-test.c
===================================================================
RCS file: /cvs/gnome/glib/tests/date-test.c,v
retrieving revision 1.2
diff -u -r1.2 date-test.c
--- tests/date-test.c 1999/04/13 21:05:07 1.2
+++ tests/date-test.c 2000/12/17 18:46:59
@@ -77,13 +77,13 @@
TEST("January 1, Year 1 created and valid", g_date_valid(d));
- j = g_date_julian(d);
+ j = g_date_get_julian(d);
TEST("January 1, Year 1 is Julian date 1", j == 1);
- TEST("Returned month is January", g_date_month(d) == G_DATE_JANUARY);
- TEST("Returned day is 1", g_date_day(d) == 1);
- TEST("Returned year is 1", g_date_year(d) == 1);
+ TEST("Returned month is January", g_date_get_month(d) == G_DATE_JANUARY);
+ TEST("Returned day is 1", g_date_get_day(d) == 1);
+ TEST("Returned year is 1", g_date_get_year(d) == 1);
TEST("Bad month is invalid", !g_date_valid_month(G_DATE_BAD_MONTH));
TEST("Month 13 is invalid", !g_date_valid_month(13));
@@ -135,9 +135,9 @@
/* Note: this test will hopefully work, but no promises. */
TEST("Successfully parsed a %x-formatted string",
g_date_valid(d) &&
- g_date_month(d) == 1 &&
- g_date_day(d) == 10 &&
- g_date_year(d) == 2000);
+ g_date_get_month(d) == 1 &&
+ g_date_get_day(d) == 10 &&
+ g_date_get_year(d) == 2000);
if (failed)
g_date_debug_print(d);
@@ -154,9 +154,9 @@
guint32 first_day_of_year = G_DATE_BAD_JULIAN;
guint16 days_in_year = g_date_is_leap_year(y) ? 366 : 365;
guint sunday_week_of_year = 0;
- guint sunday_weeks_in_year = g_date_sunday_weeks_in_year(y);
+ guint sunday_weeks_in_year = g_date_get_sunday_weeks_in_year(y);
guint monday_week_of_year = 0;
- guint monday_weeks_in_year = g_date_monday_weeks_in_year(y);
+ guint monday_weeks_in_year = g_date_get_monday_weeks_in_year(y);
if (discontinuity)
g_print(" (Break in sequence of requested years to check)\n");
@@ -174,7 +174,7 @@
m = 1;
while (m < 13)
{
- guint8 dim = g_date_days_in_month(m,y);
+ guint8 dim = g_date_get_days_in_month(m,y);
GDate days[31]; /* This is the fast way, no allocation */
TEST("Sensible number of days in month", (dim > 0 && dim < 32));
@@ -204,89 +204,89 @@
if (m == G_DATE_JANUARY && day == 1)
{
- first_day_of_year = g_date_julian(d);
+ first_day_of_year = g_date_get_julian(d);
}
g_assert(first_day_of_year != G_DATE_BAD_JULIAN);
TEST("Date with DMY triplet is valid", g_date_valid(d));
- TEST("Month accessor works", g_date_month(d) == m);
- TEST("Year accessor works", g_date_year(d) == y);
- TEST("Day of month accessor works", g_date_day(d) == day);
+ TEST("Month accessor works", g_date_get_month(d) == m);
+ TEST("Year accessor works", g_date_get_year(d) == y);
+ TEST("Day of month accessor works", g_date_get_day(d) == day);
TEST("Day of year is consistent with Julian dates",
- ((g_date_julian(d) + 1 - first_day_of_year) ==
- (g_date_day_of_year(d))));
+ ((g_date_get_julian(d) + 1 - first_day_of_year) ==
+ (g_date_get_day_of_year(d))));
if (failed)
{
g_print("first day: %u this day: %u day of year: %u\n",
first_day_of_year,
- g_date_julian(d),
- g_date_day_of_year(d));
+ g_date_get_julian(d),
+ g_date_get_day_of_year(d));
}
if (m == G_DATE_DECEMBER && day == 31)
{
TEST("Last day of year equals number of days in year",
- g_date_day_of_year(d) == days_in_year);
+ g_date_get_day_of_year(d) == days_in_year);
if (failed)
{
g_print("last day: %u days in year: %u\n",
- g_date_day_of_year(d), days_in_year);
+ g_date_get_day_of_year(d), days_in_year);
}
}
TEST("Day of year is not more than number of days in the year",
- g_date_day_of_year(d) <= days_in_year);
+ g_date_get_day_of_year(d) <= days_in_year);
TEST("Monday week of year is not more than number of weeks in the year",
- g_date_monday_week_of_year(d) <= monday_weeks_in_year);
+ g_date_get_monday_week_of_year(d) <= monday_weeks_in_year);
if (failed)
{
g_print("Weeks in year: %u\n", monday_weeks_in_year);
g_date_debug_print(d);
}
TEST("Monday week of year is >= than last week of year",
- g_date_monday_week_of_year(d) >= monday_week_of_year);
+ g_date_get_monday_week_of_year(d) >= monday_week_of_year);
- if (g_date_weekday(d) == G_DATE_MONDAY)
+ if (g_date_get_weekday(d) == G_DATE_MONDAY)
{
TEST("Monday week of year on Monday 1 more than previous day's week of year",
- (g_date_monday_week_of_year(d) - monday_week_of_year) == 1);
+ (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 1);
}
else
{
TEST("Monday week of year on non-Monday 0 more than previous day's week of year",
- (g_date_monday_week_of_year(d) - monday_week_of_year) == 0);
+ (g_date_get_monday_week_of_year(d) - monday_week_of_year) == 0);
}
- monday_week_of_year = g_date_monday_week_of_year(d);
+ monday_week_of_year = g_date_get_monday_week_of_year(d);
TEST("Sunday week of year is not more than number of weeks in the year",
- g_date_sunday_week_of_year(d) <= sunday_weeks_in_year);
+ g_date_get_sunday_week_of_year(d) <= sunday_weeks_in_year);
if (failed)
{
g_date_debug_print(d);
}
TEST("Sunday week of year is >= than last week of year",
- g_date_sunday_week_of_year(d) >= sunday_week_of_year);
+ g_date_get_sunday_week_of_year(d) >= sunday_week_of_year);
- if (g_date_weekday(d) == G_DATE_SUNDAY)
+ if (g_date_get_weekday(d) == G_DATE_SUNDAY)
{
TEST("Sunday week of year on Sunday 1 more than previous day's week of year",
- (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 1);
+ (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 1);
}
else
{
TEST("Sunday week of year on non-Sunday 0 more than previous day's week of year",
- (g_date_sunday_week_of_year(d) - sunday_week_of_year) == 0);
+ (g_date_get_sunday_week_of_year(d) - sunday_week_of_year) == 0);
}
- sunday_week_of_year = g_date_sunday_week_of_year(d);
+ sunday_week_of_year = g_date_get_sunday_week_of_year(d);
TEST("Date is equal to itself",
g_date_compare(d,d) == 0);
@@ -307,7 +307,7 @@
g_date_subtract_days(d, i);
TEST("Forward days then backward days returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -316,7 +316,7 @@
}
TEST("Forward days then backward days returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -325,7 +325,7 @@
}
TEST("Forward days then backward days returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -342,7 +342,7 @@
g_date_subtract_months(d, i);
TEST("Forward months then backward months returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -351,7 +351,7 @@
}
TEST("Forward months then backward months returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -365,7 +365,7 @@
/* Day should be unchanged */
TEST("Forward months then backward months returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -390,7 +390,7 @@
g_date_subtract_years(d, i);
TEST("Forward years then backward years returns us to current month",
- g_date_month(d) == m);
+ g_date_get_month(d) == m);
if (failed)
{
@@ -399,7 +399,7 @@
}
TEST("Forward years then backward years returns us to current year",
- g_date_year(d) == y);
+ g_date_get_year(d) == y);
if (failed)
{
@@ -410,7 +410,7 @@
if (m != 2 && day != 29)
{
TEST("Forward years then backward years returns us to current day",
- g_date_day(d) == day);
+ g_date_get_day(d) == day);
if (failed)
{
@@ -433,16 +433,16 @@
/* We can only run sequence tests between sequential years */
TEST("Julians are sequential with increment 1",
- j+1 == g_date_julian(d));
+ j+1 == g_date_get_julian(d));
if (failed)
{
g_print("Out of sequence, prev: %u expected: %u got: %u\n",
- j, j+1, g_date_julian(d));
+ j, j+1, g_date_get_julian(d));
}
g_date_add_days(d,1);
TEST("Next day has julian 1 higher",
- g_date_julian(d) == j + 2);
+ g_date_get_julian(d) == j + 2);
g_date_subtract_days(d, 1);
if (j != G_DATE_BAD_JULIAN)
@@ -450,7 +450,7 @@
g_date_subtract_days(d, 1);
TEST("Previous day has julian 1 lower",
- g_date_julian(d) == j);
+ g_date_get_julian(d) == j);
g_date_add_days(d, 1); /* back to original */
}
@@ -460,7 +460,7 @@
fflush(stdout);
fflush(stderr);
- j = g_date_julian(d); /* inc current julian */
+ j = g_date_get_julian(d); /* inc current julian */
++day;
}
cvs server: Diffing tests/markups
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]