Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc9970d5

Browse files
author
Michael Meskes
committed
Started to cleanup complex tests.
Added some interval checks to regression suite.
1 parent276b3bb commitc9970d5

25 files changed

+830
-349
lines changed

‎src/interfaces/ecpg/test/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.60 2006/08/29 12:33:45 meskes Exp $
1+
# $PostgreSQL: pgsql/src/interfaces/ecpg/test/Makefile,v 1.61 2006/09/05 12:11:01 meskes Exp $
22

33
subdir = src/interfaces/ecpg/test
44
top_builddir = ../../../..
@@ -27,7 +27,7 @@ all install installdirs uninstall dep depend distprep:
2727
$(MAKE) -C connect$@
2828
$(MAKE) -C sql$@
2929
$(MAKE) -C pgtypeslib$@
30-
$(MAKE) -Cerrors$@
30+
$(MAKE) -Cpreproc$@
3131
$(MAKE) -C compat_informix$@
3232
$(MAKE) -C complex$@
3333
$(MAKE) -C thread$@
@@ -37,7 +37,7 @@ clean distclean maintainer-clean:
3737
$(MAKE) -C connect extraclean
3838
$(MAKE) -C sql$@
3939
$(MAKE) -C pgtypeslib$@
40-
$(MAKE) -Cerrors$@
40+
$(MAKE) -Cpreproc$@
4141
$(MAKE) -C compat_informix$@
4242
$(MAKE) -C complex$@
4343
$(MAKE) -C thread$@

‎src/interfaces/ecpg/test/complex/Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ include $(top_srcdir)/$(subdir)/../Makefile.regress
66

77
TESTS = test1 test1.c\
88
test2 test2.c\
9-
test3 test3.c\
10-
test4 test4.c\
11-
test5 test5.c
9+
test3 test3.c
1210

1311
all:$(TESTS)
1412

15-
# test4 needs the -c option for the "EXEC SQL TYPE" construct
16-
test4.c: test4.pgc ../regression.h
17-
$(ECPG) -c -o$@ -I$(srcdir)$<

‎src/interfaces/ecpg/test/expected/complex-test4.stderr

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎src/interfaces/ecpg/test/expected/complex-test5.stderr

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include<stdio.h>
1111
#include<string.h>
1212
#include<stdlib.h>
13+
#include<limits.h>
1314
#include<pgtypes_date.h>
1415
#include<pgtypes_timestamp.h>
1516

@@ -21,28 +22,72 @@
2122

2223

2324

24-
#line7 "dt_test2.pgc"
25+
#line8 "dt_test2.pgc"
2526

2627

28+
char*dates[]= {"19990108foobar",
29+
"19990108 foobar",
30+
"1999-01-08 foobar",
31+
"January 8, 1999",
32+
"1999-01-08",
33+
"1/8/1999",
34+
"1/18/1999",
35+
"01/02/03",
36+
"1999-Jan-08",
37+
"Jan-08-1999",
38+
"08-Jan-1999",
39+
"99-Jan-08",
40+
"08-Jan-99",
41+
"08-Jan-06",
42+
"Jan-08-99",
43+
"19990108",
44+
"990108",
45+
"1999.008",
46+
"J2451187",
47+
"January 8, 99 BC",
48+
NULL };
49+
50+
char*times[]= {"0:04",
51+
"1:59 PDT",
52+
"13:24:40 -8:00",
53+
"13:24:40.495+3",
54+
NULL };
55+
56+
char*intervals[]= {"1 minute",
57+
"1 12:59:10",
58+
"2 day 12 hour 59 minute 10 second",
59+
"1 days 12 hrs 59 mins 10 secs",
60+
"1 days 1 hours 1 minutes 1 seconds",
61+
"1 year 59 mins",
62+
"1 year 59 mins foobar",
63+
NULL };
64+
2765
int
2866
main(void)
2967
{
3068
/* exec sql begin declare section */
3169

70+
3271

3372

3473

35-
#line13 "dt_test2.pgc"
74+
#line51 "dt_test2.pgc"
3675
datedate1 ;
3776

38-
#line14 "dt_test2.pgc"
39-
timestampts1 ;
77+
#line52 "dt_test2.pgc"
78+
timestampts1,ts2;
4079

41-
#line15 "dt_test2.pgc"
80+
#line53 "dt_test2.pgc"
4281
char*text ;
82+
83+
#line 54 "dt_test2.pgc"
84+
interval*i1 ;
4385
/* exec sql end declare section */
44-
#line 16 "dt_test2.pgc"
86+
#line 55 "dt_test2.pgc"
87+
4588

89+
inti,j;
90+
char*endptr;
4691

4792
ECPGdebug(1,stderr);
4893

@@ -57,6 +102,58 @@ main(void)
57102
printf("Date of timestamp: %s\n",text);
58103
free(text);
59104

105+
for (i=0;dates[i];i++)
106+
{
107+
boolerr= false;
108+
date1=PGTYPESdate_from_asc(dates[i],&endptr);
109+
if (date1==INT_MIN) {
110+
err= true;
111+
}
112+
text=PGTYPESdate_to_asc(date1);
113+
printf("Date[%d]: %s (%c - %c)\n",
114+
i,err ?"-" :text,
115+
endptr ?'N' :'Y',
116+
err ?'T' :'F');
117+
free(text);
118+
if (!err)
119+
{
120+
for (j=0;times[j];j++)
121+
{
122+
intlength=strlen(dates[i])
123+
+1
124+
+strlen(times[j])
125+
+1;
126+
char*t=malloc(length);
127+
sprintf(t,"%s %s",dates[i],times[j]);
128+
ts1=PGTYPEStimestamp_from_asc(t,NULL);
129+
text=PGTYPEStimestamp_to_asc(ts1);
130+
printf("TS[%d,%d]: %s\n",
131+
i,j,errno ?"-" :text);
132+
free(text);
133+
}
134+
}
135+
}
136+
137+
ts1=PGTYPEStimestamp_from_asc("2004-04-04 23:23:23",NULL);
138+
139+
for (i=0;intervals[i];i++)
140+
{
141+
i1=PGTYPESinterval_from_asc(intervals[i],&endptr);
142+
if (*endptr)
143+
printf("endptr set to %s\n",endptr);
144+
if (!i1)
145+
{
146+
printf("Error parsing interval %d\n",i);
147+
continue;
148+
}
149+
j=PGTYPEStimestamp_add_interval(&ts1,i1,&ts2);
150+
if (j<0)
151+
continue;
152+
text=PGTYPESinterval_to_asc(i1);
153+
printf("interval[%d]: %s\n",i,text ?text :"-");
154+
free(text);
155+
}
156+
60157
return (0);
61158
}
62159

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp