Skip to content

Commit

Permalink
improved test for date
Browse files Browse the repository at this point in the history
  • Loading branch information
freddy77 committed Jun 8, 2006
1 parent e592cfb commit 2e6b1b3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Thu Jun 08 10:18:50 CET 2006 Frediano Ziglio <freddyz77_A_lycos_D_com>
* src/tds/unittests/t0007.c:
- improved to detect possible date problems

Thu Jun 08 08:40:12 CET 2006 Frediano Ziglio <freddyz77_A_lycos_D_com>
* src/tds/convert.c:
- backported patch by Nick Castellano, correctly convert dates in
Expand Down
20 changes: 18 additions & 2 deletions src/tds/unittests/t0007.c
Expand Up @@ -20,7 +20,7 @@
#include "common.h"
#include <tdsconvert.h>

static char software_version[] = "$Id: t0007.c,v 1.13 2005-06-29 07:21:37 freddy77 Exp $";
static char software_version[] = "$Id: t0007.c,v 1.13.2.1 2006-06-08 08:19:32 freddy77 Exp $";
static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };

static TDSCONTEXT ctx;
Expand Down Expand Up @@ -63,11 +63,16 @@ test0(const char *src, int len, int dsttype, const char *result)
sprintf(strchr(buf, 0), " %02X", (TDS_UCHAR) cr.ib[i]);
free(cr.ib);
break;
case SYBDATETIME:
sprintf(buf, "%ld %ld", (long int) cr.dt.dtdays, (long int) cr.dt.dttime);
break;
}
}
printf("%s\n", buf);
if (strcmp(buf, result) != 0)
if (strcmp(buf, result) != 0) {
fprintf(stderr, "Expected %s\n", result);
exit(1);
}
}

void
Expand Down Expand Up @@ -137,5 +142,16 @@ main(int argc, char **argv)
test("0x100", SYBBINARY, "len=2 01 00");
test("0x1", SYBBINARY, "len=1 01");

test("Jan 01 2006", SYBDATETIME, "38716 0");
test("January 01 2006", SYBDATETIME, "38716 0");
test("March 05 2005", SYBDATETIME, "38414 0");
test("may 13 2001", SYBDATETIME, "37022 0");

test("02 Jan 2006", SYBDATETIME, "38717 0");
test("2 Jan 2006", SYBDATETIME, "38717 0");
test("02Jan2006", SYBDATETIME, "38717 0");
test("20060102", SYBDATETIME, "38717 0");
test("060102", SYBDATETIME, "38717 0");

return 0;
}

0 comments on commit 2e6b1b3

Please sign in to comment.