svn commit: samba r22224 - in
branches/SAMBA_3_0/source/lib/replace/test: .
metze at samba.org
metze at samba.org
Sun Apr 15 20:57:49 GMT 2007
Author: metze
Date: 2007-04-15 20:57:48 +0000 (Sun, 15 Apr 2007)
New Revision: 22224
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22224
Log:
merge from samba4:
make comparing of struct tm more verbose and portable
metze
Modified:
branches/SAMBA_3_0/source/lib/replace/test/strptime.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/replace/test/strptime.c
===================================================================
--- branches/SAMBA_3_0/source/lib/replace/test/strptime.c 2007-04-15 20:55:52 UTC (rev 22223)
+++ branches/SAMBA_3_0/source/lib/replace/test/strptime.c 2007-04-15 20:57:48 UTC (rev 22224)
@@ -8,6 +8,10 @@
#define true 1
#define false 0
+#ifndef __STRING
+#define __STRING(x) #x
+#endif
+
/* make printf a no-op */
#define printf if(0) printf
@@ -24,6 +28,9 @@
char *ret;
struct tm t, t2;
+ memset(&t, 0, sizeof(t));
+ memset(&t2, 0, sizeof(t2));
+
printf("test: strptime\n");
ret = strptime(s, "%Y%m%d%H%M%S", &t);
@@ -56,13 +63,26 @@
return false;
}
- if (memcmp(&t, &t2, sizeof(t)) == 0) {
- printf("failure: strptime [\n"
- "result differs if the format string has a 'Z' at the end\n"
- "]\n");
- return false;
+#define CMP_TM_ELEMENT(t1,t2,elem) \
+ if (t1.elem != t2.elem) { \
+ printf("failure: strptime [\n" \
+ "result differs if the format string has a 'Z' at the end\n" \
+ "element: %s %d != %d\n" \
+ "]\n", \
+ __STRING(elen), t1.elem, t2.elem); \
+ return false; \
}
+ CMP_TM_ELEMENT(t,t2,tm_sec);
+ CMP_TM_ELEMENT(t,t2,tm_min);
+ CMP_TM_ELEMENT(t,t2,tm_hour);
+ CMP_TM_ELEMENT(t,t2,tm_mday);
+ CMP_TM_ELEMENT(t,t2,tm_mon);
+ CMP_TM_ELEMENT(t,t2,tm_year);
+ CMP_TM_ELEMENT(t,t2,tm_wday);
+ CMP_TM_ELEMENT(t,t2,tm_yday);
+ CMP_TM_ELEMENT(t,t2,tm_isdst);
+
if (t.tm_sec != 46) {
printf("failure: strptime [\n"
"tm_sec: expected: 46, got: %d\n"
More information about the samba-cvs
mailing list