Skip to content

Commit

Permalink
Improve libTDS tests for new big(date)time types
Browse files Browse the repository at this point in the history
convert test test all conversion combination to make sure that a
conversion is present is declared so or viceversa.
t0007 test some conversions checking for data.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
  • Loading branch information
freddy77 committed Sep 21, 2015
1 parent 88cfea1 commit abcc09c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/tds/unittests/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ main(int argc, char **argv)
TDS_DATETIMEALL dta;
TDS_DATE date;
TDS_TIME time;
TDS_BIGDATETIME bigdatetime;
TDS_BIGTIME bigtime;

TDS_TINYINT tds_tinyint;
TDS_SMALLINT tds_smallint;
Expand Down Expand Up @@ -165,6 +167,12 @@ main(int argc, char **argv)
case SYBTIME:
src = "15:27:12";
break;
case SYB5BIGTIME:
src = "15:27:12.327862";
break;
case SYB5BIGDATETIME:
src = "2015-09-12 21:48:12.638161";
break;
case SYBBINARY:
case SYBIMAGE:
src = "0xbeef";
Expand Down Expand Up @@ -273,6 +281,14 @@ main(int argc, char **argv)
src = (char *) &time;
srclen = sizeof(time);
break;
case SYB5BIGTIME:
src = (char *) &bigtime;
srclen = sizeof(bigtime);
break;
case SYB5BIGDATETIME:
src = (char *) &bigdatetime;
srclen = sizeof(bigdatetime);
break;
case SYBUNIQUE:
src = (char *) &tds_unique;
srclen = sizeof(tds_unique);
Expand Down Expand Up @@ -352,6 +368,12 @@ main(int argc, char **argv)
case SYBMSDATETIME2:
dta = cr.dta;
break;
case SYB5BIGTIME:
bigtime = cr.bigtime;
break;
case SYB5BIGDATETIME:
bigdatetime = cr.bigdatetime;
break;
case SYBINT1:
case SYBUINT1:
tds_tinyint = cr.ti;
Expand Down
9 changes: 9 additions & 0 deletions src/tds/unittests/t0007.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ test0(const char *src, int len, int midtype, int dsttype, const char *result, in
case SYBINT8:
sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.bi >> 32) & 0xfffffffflu), (unsigned int) (cr.bi & 0xfffffffflu));
break;
case SYB5BIGTIME:
case SYB5BIGDATETIME:
case SYBUINT8:
sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.ubi >> 32) & 0xfffffffflu), (unsigned int) (cr.ubi & 0xfffffffflu));
break;
Expand Down Expand Up @@ -327,6 +329,13 @@ main(int argc, char **argv)
test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBDATE, "38717");
test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBTIME, "13588901");

test("2006-01-02 12:34:56.337321", SYB5BIGTIME, "0x0000000a8bdf41a9");
test("2006-01-23 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e7c784d661a9");
test("2006-01-02 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e621122b81a9");

test2("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, SYBCHAR, "len=26 2006-01-02 12:34:56.337765");
test("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, "0x00e0e621122b8365");

test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBDATE, "38717");
test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBTIME, "13588901");

Expand Down

0 comments on commit abcc09c

Please sign in to comment.