summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-04-15 20:55:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:50:40 -0500
commit7b2b43920ba3f15c8c5db65b4be1d70bdbab2d1f (patch)
treed7011d80023c446e43524fc392d9432a30f95bed /source4/lib/replace
parentaeb3f7fb9a4bbe63e56541a78836c367fe65b821 (diff)
downloadsamba-7b2b43920ba3f15c8c5db65b4be1d70bdbab2d1f.tar.gz
samba-7b2b43920ba3f15c8c5db65b4be1d70bdbab2d1f.tar.bz2
samba-7b2b43920ba3f15c8c5db65b4be1d70bdbab2d1f.zip
r22223: make comparing of struct tm more verbose and more portable
metze (This used to be commit 2552a3300ba94b48e447e82f6b1d2ffa76d5c660)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/test/strptime.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/source4/lib/replace/test/strptime.c b/source4/lib/replace/test/strptime.c
index 434b5d0933..fade3ecc57 100644
--- a/source4/lib/replace/test/strptime.c
+++ b/source4/lib/replace/test/strptime.c
@@ -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 @@ int libreplace_test_strptime(void)
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 @@ int libreplace_test_strptime(void)
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"